Share via


Cannot Find Server (404) or Get Plain Text for WCF .svc Files From IIS?

Question

After upgrading WCF (or NetFx-3.0) from an older beta version to RC1, I get “Page Not Found” (404) error or get the plain text content of the .svc file for .svc files. Is .svc extension removed from IIS?

Why?

If you installed WCF or NetFx-3.0 RC1 or later versions, you may get this problem. On Windows XP SP2, you may get the plain text of the .svc file. On Windows 2003 Server, you may get error like “Cannot find the page” (404) error. It looks like .svc extension is not supported in IIS.

Is .svc mapping removed from IIS? No. Definitely not! The reason why you saw this is because your IIS Metabase got messed up by an earlier WCF installer due to a nasty bug. You need to clean up the IIS Metabase manually so that it works again. How? Please keep on reading.

Before RC1, there was a bug in WCF installer. It accidentally populates .svc mapping to every path/node in IIS Metabase. This messed up the Metabase and has potential security concern. Fortunately, we found this issue in RC1 and fixed it. By fixing it, we only install .svc mapping to the template of the root /W3SVC of IIS Metabase. However, those machines with earlier WCF beta versions installed still have the messy ScriptMaps. They stop the inheritance of the .svc ScriptMaps from the template at the root /W3SVC. This is especially true for the “Default Web Site” and its virtual applications.

If you create a new web site with WCF RC1 installed, you won’t have this problem for that web site.

Solutions

Here are different ways that can help you to resolve the problem:

· Download tool: CleanIISScriptMaps.exe

Please find the tool “CleanIISScriptMaps.exe” in the attached zip file. The source for the tool is also included. You also find this tool and corresponding information on https://wcf.netfx3.com/files/folders/product_team/entry5648.aspx. The usage for this tool is simple, just run it without any argument from any command window. After running it, everything should just work fine. You don’t need to rerun any other setup.

If you find that .svc is still not supported for some virtual directories but you want them to be supported as well, you can run the tool with more options to explicitly remove the ScriptMaps properties from those paths. Here is the full usage of the tool:

Usage: CleanIISScriptMaps <options>

Options:

By default, the tool removes redundant ScriptMaps properties.

/f Remove ScriptMaps from all nodes in IIS Metabase except for

the root "/W3SVC".

/p Prompt for confirmation when removing ScriptMaps at a node

that is different than that of the root "/W3SVC".

/v Print out verbose information.

/? Print this help.

· Reinstall IIS or re-create web sites

You can uninstall IIS and reinstall it so that the IIS Metabase is cleaned up. Then you will need to run the WCF install tool manually as following:

"%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" /r /y

If you are running Windows 2003 Server, you may be able to delete the “Default Web Site” and re-create it. The problem will be fixed as well.

· Install .svc manually as a temporary workaround

You can run the following command to install .svc mapping manually. However, this does not clean up the mess of the IIS Metabase. You will see the same problem again when you install newer WCF. So this is the least recommended approach comparing to the above two options:

"%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" /s:W3SVC

Though this does not clean up the Metabase for you, it does not mess up new web sites.

CleanIISScriptMaps.zip

Comments

  • Anonymous
    September 19, 2006
    My team has been working on a very cool demo scenario for a few months now.&amp;nbsp;&amp;nbsp; We've upgraded...

  • Anonymous
    January 18, 2007
    In this post , I pointed to some problems that may arise when you try to host Windows Communication Foundation

  • Anonymous
    September 28, 2007
    I was able to resovlve this issue only after going through the repair process of .NET framework 3.0...

  • Anonymous
    April 14, 2008
    CleanIISScriptMaps.exe works fine. I needed it on 2 different Windows XP machines and it solved the problem.