WCF: HTTP 404 when hosted in IIS

By jpsmit
January 17, 2007

While playing with WCF I ran into someting when I wanted to host the service in IIS.

I created a ‘service.svc’ in a folder, added a web.config, created a bin folder to put the assembly in, and added a website to that folder in IIS. According to the MSDN documentation and several blogposts, that was enough to host the WCF service in IIS.

But when I tried to browse the service, I received an HTTP 404 error.

In the release notes of the .NET 3.0 framework I found the following, which I thought should solve the problem because it exactly describes my problem.

2.7.4 May not be able to web host WCF services if a pre-RC1 version of WCF was previously installed

If you installed a previous version of the .NET Framework 3.0 while IIS was installed, when you upgrade to the RTM version of the .NET Framework 3.0 you may have difficulty accessing WCF services that are IIS hosted using .svc files. On computers running Windows Server 2003, accessing an .svc extension from the browser may return a “404: Page Not Found” error. On computers running Windows XP, the .svc content may be displayed as plain text.

This is due to an issue with WCF script map registrations in a previous release.   

To resolve this issue

There are three ways to work around this issue:

  1. Download the unsupported tool, CleanIISScriptMaps.exe from http://wcf.netfx3.com/files/folders/product_team/entry5648.aspx. Run the tool from a command console without any arguments.
  2. Uninstall and reinstall IIS or re-create your Web sites:

    1. Uninstall IIS and reinstall it so that the IIS Metabase is refreshed. Then run the WCF install tool manually to re-register the WCF scriptmaps:
      “%windir%Microsoft.NETFrameworkv3.0Windows Communication FoundationServiceModelReg.exe” /r /y

    2. If you are running Windows 2003 Server, you may be able to resolve the problem by deleting the “Default Web Site” and re-creating it.

  3. Install .svc manually as a temporary workaround:
    You can run the following command to install .svc mapping manually. However, this refreshes the IIS Metabase for existing sites. “%windir%Microsoft.NETFrameworkv3.0Windows Communication FoundationServiceModelReg.exe” /s:W3SVC

After trying all this, still a 404. 🙁
What actually caused the problem was the fact that I forgot to mark the website as a .NET 2.0 website instead of a 1.1 site which is the default.


Comments: 0

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Recent Posts
  • Recent Comments
  • Archives
  • Categories
  • Meta