Friday, July 23, 2010

Hosting WCF services in IIS7 and Windows Vista

Link from http://live.mscommunity.net/blogs/borissevo/archive/2007/10/30/hosting-wcf-services-in-iis7-and-windows-vista.aspx

Hosting WCF services in IIS7 and Windows Vista

Today I spent almost 2 hours trying to run a WCF service hosted in IIS7. After I read a lot of blog and forum posts I finally got a solution which works. Basically, you just need to do this four steps:

Step1: Change the C:\Windows\System32\inetsrv\config\applicationHost.config file. You must add handlers section and one mimeMap tag.

<location path="Default Web Site" overrideMode="Allow">
<system.webServer>
<asp />
<handlers>
<add name="svc-Integrated" path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="integratedMode" />
<add name="svc-ISAPI-2.0" path="*.svc" verb="*" modules="IsapiModule" scriptProcessor="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
</handlers>
</system.webServer>
</location>
...
<staticContent>
...
<mimeMap fileExtension=".svc" mimeType="application/octet-stream" />
...
</staticContent>

Step2: Then you should run servicemodelreg with a -i option:
C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation>ServiceModelReg -i

Step3: Turn a Windows Communication Foundation HTTP Activation feature on. Go to Add/Remove programs, Turn Windows Features on/off and install Windows Communication Foundation HTTP Activation (it is in a Microsoft .NET Framework 3.0 section).

Step4: Go to IIS Manager and add new application to your web site (you must choose Add Application ... option, I also tried with a Add Virtual Directory ..., but it didn't work for me) which physical path will point to your WCF service.

That's all. I hope it will help you if you run in a similar problem.