我正在使用VS2010 + C#+ .Net 4.0 + IIS 7.5 + Windows7。当我在IIS中打开WCF项目的svc文件(在IIS管理器中,右键单击该svc文件并选择浏览)时,出现了这样的错误,有什么主意吗?
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.
这是我正在使用的web.config文件的内容,对吗?
<?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>
最佳答案
您可能必须在Visual Studio命令提示符下启动命令servicemodelreg –ia
。
如果不起作用,请检查是否安装了“ WCF http激活”功能(“添加/删除程序-启用或禁用Windows功能-Microsoft .Net 3.5.1”)。
更新1:可能您的应用程序托管在.NET 2.0 App Pool下。转到IIS管理器并检查“基本设置”链接。单击选择按钮,您将看到您正在使用哪个选项。更改为使用.NET 4.0
更新2:您的web.config文件似乎不完整。我建议您使用WCF Configuration Editor工具配置服务。启动它(确保您使用的是.NET 4版本的工具),然后打开web.config文件。创建服务配置和服务端点配置,然后将其保存。