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

Hel*_*ent 3 iis wcf web-config visual-studio-2010 asp.net-4.0

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

我在本地Web服务器上收到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>
Run Code Online (Sandbox Code Playgroud)

它在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元素"编译"具有无效的子元素"身份验证".预期可能元素的列表:'assemblies,buildProviders,codeSubDirectories,expressionBuilders,folderLevelBuildProviders'.p:\ jcp\WCF1\WCF1\Web.config 5 5 WCF1

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

Joh*_*err 8

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

  1. Web.configs是案例敏感的.你需要驼峰您的文本(例如system.webServer,targetFramework,system.serviceModel).
  2. system.web.authentication是一个同伴system.web.compilation,而不是它的孩子.