WCF Web.config - 无法读取配置节'system.webserver',因为它缺少节声明

时间:2013-01-27 13:22:46

标签: visual-studio-2010 wcf iis web-config asp.net-4.0

我在Visual Studio 2010上,目标是4.0。这个web.config有什么问题?

我在本地网络服务器上收到500错误: 无法读取配置部分'system.webserver',因为它缺少部分声明

<?xml version="1.0"?>
<configuration>
    <system.web>
        <compilation debug="true" targetframework="4.0">
            <authentication mode="None">
            </authentication>
        </compilation>
    </system.web>
    <system.webserver>
        <modules runallmanagedmodulesforallrequests="true">
        </modules>
    </system.webserver>
    <system.servicemodel>
        <servicehostingenvironment aspnetcompatibilityenabled="true">
            <standardendpoints>
                <webscriptendpoint>
                    <standardendpoint crossdomainscriptaccessenabled="true">
                    </standardendpoint>
                </webscriptendpoint>
            </standardendpoints>
        </servicehostingenvironment>
    </system.servicemodel>
</configuration>

它在VS中给了我这些警告:

警告1 p:\ jcp \ WCF1 \ WCF1 \ Service1.svc:ASP.NET运行时错误:无法识别的配置部分system.webserver。 (p:\ jcp \ WCF1 \ WCF1 \ web.config第9行)p:\ jcp \ WCF1 \ WCF1 \ Service1.svc 1 1 WCF1

警告2不允许使用'targetframework'属性。 p:\ jcp \ WCF1 \ WCF1 \ Web.config 4 29 WCF1

警告3元素'compilation'具有无效的子元素'authentication'。预期可能元素的列表:'assemblies,buildProviders,codeSubDirectories,expressionBuilders,folderLevelBuildProviders'。 p:\ jcp \ WCF1 \ WCF1 \ Web.config 5 5 WCF1

我已将项目设置为使用本地IIS并在虚拟上创建。我的客户端是带有iis7的Windows 7专业版,该文件夹的apppool设置为4.0。我是否需要在客户端安装.net 3.5?

2 个答案:

答案 0 :(得分:7)

我认为有几个问题可能会导致您遇到的错误:

  1. Web.configs案例敏感。您需要对自己的文字进行驼峰式处理(例如system.webServertargetFrameworksystem.serviceModel。)
  2. system.web.authenticationsystem.web.compilation的同伴,而不是其中的孩子。

答案 1 :(得分:1)

我也有这个拼写错误,带我几次看到我错过了环境中的'n',值得将整个文件放在VS proj中让它测试它

相关问题