Partager via


IIS7: WCF Services - .SVC do not work

Recently I came across a problem with Windows Communication Foundation Services and IIS 7.

What I did is, deploy a .SVC file to my IIS 7.

The service worked during development on the local ASP.NET Dev Webserver, but after deploying it to the server, there was an error:

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

The configuration section 'system.serviceModel' cannot be read because it is missing a section declaration.

Another error might be:

Unhandled Exception: System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (405) Method not allowed

After some research I found the problem: WCF Services are not registered on the IIS!

To fix it, follow these steps:

  1. Make sure ASP.NET pages work on IIS (if not see below).
  2. Execute the following command with elevated privileges (as administrator):
    "%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -i

If ASP.NET pages neither work, register ASP.NET first:

  1. Open a command prompt as administrator.
  2. Execute the follow command:
    "%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe" –i

For more details see the MSDN documentation:

Comments

  • Anonymous
    January 06, 2010
    I spent quite a lot time as I was getting 405 error for svc. I register the WCF on service and its working now. Thanks.