IIS Hosted Service Fails
If an IIS hosted service fails you may see any of the following symptoms:
When browsing to a .svc file, the file is not recognized, the browser shows a blank page, or the text of the file is displayed instead of the service's help page as in the following example.
<%@ServiceHost language=c# Debug="true" Service="Microsoft.ServiceModel.Samples.CalculatorService" %>
When attempting to access a Web-hosted service, you may encounter the following exception:
Unhandled Exception: System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (405) Method not allowed.
This typically occurs if ASP.NET is not installed or the .svc file type is not mapped to the aspnet_isapi.dll.
To correct this you must make sure that aspnet_isapi is enabled as a Web service extension for IIS. You can view and modify this setting using IIS Manager, or by running aspnet_regiis –I –enable
from the .NET Framework installation directory. Once you have done so, verify that ASP.NET is running. To do so, place a test .aspx file in the \inetpub\wwwroot directory, and make sure it can be browsed with a browser.
If you installed IIS after Windows Communication Foundation (WCF) was installed you must run the following:
"%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r
This registers the required script maps in IIS.
You must also make sure that the .svc file type is mapped to aspnet_isapi.dll.
To verify that the svc file type is mapped to be handled by aspnet_isapi.dll in IIS 5.1 or 6.0
Open Computer Management in Control Panel.
Expand Services and Applications, Internet Information Services.
Right-click Web Sites and select Properties.
On the Home Directory tab, click Configuration.
In the list of application mappings, verify that the .svc file is mapped to the aspnet_isapi.dll. If the file has not been mapped:
Click Add.
In the Add/Edit Application Extension Mapping dialog box, click Browse.
Browse to the folder that contains the aspnet_isapi.dll, and click Open.
Specify .svc as the extension.
Make sure Check that file exists is unchecked.
Click OK, and OK again to return to the Web Sites Properties dialog box.
Click OK to close the dialog box.
To verify that the svc file type is mapped correctly in IIS 7.0
Open a command prompt window and type start inetmgr to open the Internet Information Services (IIS) MMC snap-in.
In the left pane, expand the node with the computer's name, then expand the Web Sites node, and then select the Default Web Site.
Double-click Handler mappings in the Features View.
In the list of application mappings, verify that the .svc file is mapped to the aspnet_isapi.dll. If the file has not been mapped:
Click Add Managed Handler.
Type *.svc into the Request path:
Type System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 into the Type textbox.
Type svc-Integrated into the Name: textbox.
Click OK.
Click Add Script Map.
Type *.svc into the Request path:
Type %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll into the Executable: text box.
Type svc-ISAPI-2.0 into the Name: text box.
Click OK.
See Also
Concepts
Internet Information Service (IIS) Hosting Instructions
Send comments about this topic to Microsoft.
© Microsoft Corporation. All rights reserved.