Update: there is an updated version of this post: Enable .NET 4.0 WCF hosing in IIS 8
As I was playing with WCF services on Windows 7, I had to set up IIS to host a WCF service. It turned out that it is not as straightforward as I expected. Here is a small summary about the steps that you have to do. (I have found a post of Pandurang Nayak that describes these steps, but that article is not available currently, only through Live Search cache).
- Don’t forget to install IIS… :) Yes, it took me some time to realize that it is not installed by default.
- When you install IIS (Contol Panel / Programs / Turn Windows features on or off), the sub-components selected by default are not enough. You need at least the Windows authentication, the IIS 6 Management Compatibility (for Visual Studio) and probably some more, but I gave up playing with the sub-components and finally selected all.
Don’t forget to restart your machine. Although you are not asked to do that, for me it did not work.
- Still in the “Turn Windows features on or off” dialog, you have to enable sub components of .NET 3.5: WCF HTTP and Non-HTTP Activation. (Did you know that you can do such things here?)
- As I have installed IIS after installing Visual Studio 2008, I had to register the ASP.NET components for IIS by executing C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe –i
- Finally you have to register WCF as well for IIS (to understand the .svc extension for example). You can do it by executing C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe –i
If you have followed these steps (plus maybe a few more restart) you will be able to host WCF services on IIS 7.
Visual Studio 2008 can help you to configure and debug the virtual directory for you, but for this feature you have to run Visual Studio as administrator.
But fortunately there is an informative error message if you forget to do so.