views:

82

answers:

2

Hello everyone,

I am using VSTS 2010 + C# + .Net 4.0 + IIS 7.5 + Windows 7. When I open an svc file (in IIS manager, right click the svc file and select browse) for a WCF project in IIS, there is an error like this, any ideas what is wrong?

This type of page is not served. 
Description: The type of page you have requested is not served because it has been explicitly forbidden.  The extension '.svc' may be incorrect.   Please review the URL below and make sure that it is spelled correctly.

Here is the content of the web.config file I am using, is it correct?

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <remove fileExtension=".svc" />
        </staticContent>
        <handlers>
            <remove name="svc-ISAPI-2.0" />
            <remove name="svc-Integrated" />
            <add name="svc-ISAPI-2.0" path="*.svc" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
        </handlers>
    </system.webServer>
</configuration>

regards, George

+1  A: 

Its likely the mime types not setup correctly on IIS, try using the aspnet_regiis tool. Failing that, I'd recommend adding a mimetype to your virtual directory in iis for .svc files to be handled by the .NET runtime.

Nate Bross
Thanks! I should run aspnet_regiis with what options? And I should run aspnet_regiis under .Net 4.0, correct?
George2
I tried your solution, but met with a new issue => http://stackoverflow.com/questions/3776493/loading-error-for-system-servicemodel-activation-httpmodule I am confused why there is error regarding loading 3.0 Service Model error. My code is built for .Net 4.0.
George2
I am also suspecting the web.config is not correct. I have posted the web.config I am using in original post, any ideas?
George2
+1  A: 

You may have to launch the command servicemodelreg –ia in Visual Studio command prompt.

If it's not working, check if you have "WCF http activation" feature installed (Add/Remove Programs - Turn Windows Features On or Off - Microsoft .Net 3.5.1).

UPDATE 1: Probably your application is hosted under .NET 2.0 App Pool. Go to IIS Manager and check for Basic Settings… link. Click Select button and you will see which option are you using. Change it to use .NET 4.0

UPDATE 2: Your web.config file seems incomplete. I suggest you to configure your service using WCF Configuration Editor tool. Launch it (make sure you are using .NET 4 version of the tool) and open your web.config file. Create service configuration and service endpoint configuration, then save it.

Artem K.
Thanks! I should run servicemodelreg under C:\Windows\Microsoft.NET\Framework\v4.0.30319? Or under C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation?
George2
I tried your solution, but met with a new issue => http://stackoverflow.com/questions/3776493/loading-error-for-system-servicemodel-activation-httpmodule I am confused why there is error regarding loading 3.0 Service Model error. My code is built for .Net 4.0.
George2
I am also suspecting the web.config is not correct. I have posted the web.config I am using in original post, any ideas?
George2
Please check update
Artem K.
I have checked that I am using .Net 4.0 Integrated pool. Any further ideas? Do you think my web.config is correct?
George2
Is this complete web.config? If yes, you missing the whole WCF configuration part system.serviceModel, check another update
Artem K.
Thanks Artem! I should add the WCF configuration directly to the web.config of the WCF component IIS virtual directory (i.e. the virtual directory where svc file exists)? Adding to the parent IIS virtual directory does not work?
George2
Configuration should be placed in the root *application* (not web site) directory. E.g. if you added it using "add application" in IIS manager - that's a root of the application.
Artem K.
Thanks, question answered!
George2