Monday, November 15, 2010

IIS7 configuration for hosting WCF services

I have recently been learning about Windows Communication Foundation Services and when I first tried to host a service in IIS7, I encountered the following error when attempting to navigate to the service URL:
HTTP Error 404.3 – Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map. Detailed Error InformationModule StaticFileModule.
This error is caused by enabling IIS after Visual Studio 2008/2010 and the .NET 3.5/4.0 Framework were installed.  To rectify this:

  1. Open the Visual Studio command prompt as "Administrator".
  2. Navigate to C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation.
  3. Run the following command: servicemodelreg –i.
After performing the above steps, navigating to the service URL returned the following error:
HTTP Error 500.21 - Internal Server Error
Handler "svc-Integrated" has a bad module "ManagedPipelineHandler" in its module list
As I had enabled IIS after installing Visual Studio and the .NET Framework, ASP.NET had to be registered in IIS:

  1. Open the Visual Studio command prompt as "Administrator".
  2. Navigate to C:\Windows\Microsoft.NET\Framework\v4.0.30319.
  3. Run the following command: aspnet_regiis -i
I was then able to successfully load the WCF service URL.