Gáspár Nagy on software

coach, trainer and bdd addict, creator of SpecFlow

Enable .NET 4.0 WCF hosing in IIS 8

by Gáspár on January 23, 2014

I still receive quite a lot of hits to my blog post from 2009 on hosting WCF in IIS 7. At that time we used .NET 3.5 and I had a Windows 7 machine with Visual Studio 2008. The time has passed since then and many things changed, but sometimes you still need to host WCF services with IIS. So this post shows the steps you have to do today, especially for setting up the hosing on a developer machine. If you get the 404.17 error with the message “The requested content appears to be script and will not be served by the static file handler.”, these steps might help.

My setup is a Windows 8 Enterprise (so IIS 8.0) and I have Visual Studio 2012 and 2013 installed. The steps are for a .NET 4.5 WCF service, but generally they should be the same for any application uses .NET 4.0 or above.

Prerequisite: make sure that IIS with ASP.NET integration is installed

The easiest way to check this is to create a minimalistic web application (e.g. ASP.NET MVC with “No Authentication”) and try to host it in IIS (see configuration steps below). If something is missing, make sure that:

  1. Turn Windows Features on or off - Windows 8Internet Information Services” and “Word Wide Web Services” are enabled in the “Turn Windows Features on or off” dialog.
  2. If IIS is up and running, but the ASP.NET integration is missing (you can check the ISAPI filters in IIS Manager), you should run “%WINDIR%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe –i” and hope for the best (maybe restart the machine afterwards).

Let’s try with WCF!

Add Website in IISLet’s say you have a WCF service, created with the “WCF Service Application” project type. In this kind of WCF apps, the services provided by the application are represented as “.svc” files. Hosting this application in IIS means that you create a virtual directory in IIS, where you link the root folder of your project to a URL. You also need to specify an app pool to be used, which should match to the .NET framework you target (e.g. “.NET v4.5”).


If you have configured this and try to browse one of your .svc files within the specified URL, you should see a page with some positive messages (you have created a service – but how does it know that it was me?) and links to the WSDL contracts. If you see this, then stop reading, you are done.

IIS Error in Browser - HTTP Error 404.17 - Not Found, The requested content appears to be script and will not be served by the static file handler.It can happen, however, that you receive an error page, “HTTP Error 404.17 – Not Found”, “The requested content appears to be script and will not be served by the static file handler.”. This most probably means that your IIS is not configured to host WCF services (this seems to be the default).


With .NET 3.5, you had to run the “ServiceModelReg.exe” tool, but this doesn’t seem to be necessary anymore for .NET 4.0+ (“aspnet_regiis” does this already). If you look into the details of the IIS settings, you can see some references to WCF.

Enable "HTTP Activation" in Windows Features dialogThe only thing you have to do is to enable “HTTP Activation” in the “Turn Windows Features on or off” dialog under the “WCF Services” node. With this, you basically enable the creation of WCF service instances to serve requests coming through HTTP. (BTW, this is such a fundamental change in the system that you might need to restart the machine… at least I had to.)


That’s it! Get the page again and you should not see the error anymore.

WCF service successfuly hosted in IIS

Debugging through IIS

Although the built-in web servers in Visual Studio (cassini, IIS express) are pretty good, you might also need to debug the application through the IIS hosting. For this you have to take the following steps.

  1. Setup IIS for debugging in Visual StudioRestart Visual Studio as Administrator. This is important. If you try the settings below in normal mode, you won’t get an error message, but they will not be used.
  2. Open the project properties of the WCF service application and select the “Web” tab.
  3. Change the dropdown under the “Servers” section to “Local IIS” and specify the configured URL.
  4. Place breakpoints into the service implementation code.
  5. Select the “.svc” file in solution explorer.
  6. Start debugging (F5). The WCF Test Client will pop up, where you can invoke your service methods.

Invoke service from WCF Test Client

3 thoughts on “Enable .NET 4.0 WCF hosing in IIS 8

  1. Rajneesh Sharma says:

    Thanks a lot dear… this thing bugged me for many hours…

  2. Ricker Silva says:

    I just try everything you said and My WCF still shows 404.17. this is .net 3.5 wcf. SO I think I run servicemodelreg -i but it still does not work. I even make sure to have installed WCF for 3.5 and 4 but nothing seem to work. Any other clues? In my despair I checked almost all the options in turn windows features on or off under .ne frmaework, I only leave CGI unchecked and just the default in the other options. I really don´t know why this happens in VS2013. I have win 8.1.

  3. Ricker Silva says:

    I think I forgot to mention that this is hapening when I click on view in browser over the svc file in VisualStudio. This very service is deployed trouble-free in production, but now I need to test a thing or two and look the wall in front. it is frustrating but your post is quite very complete