Monday, September 3, 2012

WCF on IIS and Windows 8

Just spend some time getting a simple WCF service up and running under IIS on my Windows 8 machine. Apparently, if you install IIS after installing the last .NET framework (ie. installing Visual Studio 2012), not all necessary handlers, adapters and protocols for WCF are installed on your IIS.

First time I tried to reach the WCF service it gave me an error that said 'The page you are requesting cannot be served because of the extension configuration.' This means you need to run Servicemodelreg.exe to reregister WCF (same kind of registration you needed from time to time for ASP .NET on previous versions of IIS, remember aspnet_regiis). You can find this tool at C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation for version 3.0 or at C:\Windows\Microsoft.NET\Framework\v4.0.30319 for version 4.0.

Now looking at the MSDN site, they will tell you to run the 3.0 version. After doing so, however, you won't have the necessary handlers installed for a WCF service created with Visual Studio 2012, since they are all version 4.0. So that won't work.

Running the 4.0 version however won't work either. If you try Servicemodelreg.exe -i it will tell you to register with the -c option (register a component). If you try the -i -c option you will get the error (and the solution!) that this tool cannot be used on this version of windows. What you can use, though, is the 'Turn Windows Features On/Off' dialog.

So simply open this up from your control panel (I pinned my control panel to my start page on day one of installing Windows 8, otherwise I wouldn't be able to find it again) and check the necessary WCF features you want to have available on your WCF. In most cases, just flagging HTTP will do. You can find the WCF features under .NET Framework 4.5 Advanced Services.


And that's what you need to get yuor WCF service running under IIS on Windows 8. Hope this was helpful.

Addendum: This fix recently also solved the issue of a 'HTTP Error 400. The request hostname is invalid' error of a colleague when trying to run a WCF service on Windows 8.

12 comments:

  1. I spent the last 3 hours trying to get a site working on my local machine that uses .svc mapped to wcf in windows 8. I ran into all the problems you pointed out, and didn't find the WCF options in the Windows Features section until I found this post. Thanks for helping solve this problem!

    Chris May / chrismay.org

    ReplyDelete
  2. Thank you very much...

    I do not understand why my WCF + framework 4.0 Need 4.5 WCF HTTP service enable..

    But it´s work..

    Sorry about poor English...

    ReplyDelete
  3. Thank you so much for this post! I especially appreciated the screenshot showing exactly which options to check/install to get my WCF service working! You saved me so much time not having to troubleshoot this myself!

    Thank you!

    ReplyDelete
  4. I just got Windows 8 installed and I was facing this issue with WCF service.
    The description which you gave was crystal clear and fixed my issue in less than 5 mins.

    Thanks a ton

    ReplyDelete
  5. Many thanks for this brilliant post! Many points have extremely useful. Hopefully you'll continue sharing your knowledge around. startup programs

    ReplyDelete
  6. Thank you!! I am glad that i found this post. I didnt expend that much time trying to figuring out. now, i know Sitefinity will tell you all features that you need to have on in windows 2012/IIS 8.

    ReplyDelete
  7. Thank a lot.

    It is still working with IIS 10 on Windows 10 Home.
    Just .Net framework in the list is 4.7 and not 4.5

    ReplyDelete
  8. Thank you.. This also worked for me on IIS 10.

    ReplyDelete
  9. i have already above window feature setting but my .svc file downloaded not browsing why?

    ReplyDelete
  10. Thanks a lot for this, it has saved me lots of time surfing for the answer.

    ReplyDelete