【问题标题】:WCF Web.config - The configuration section 'system.webserver' cannot be read because it is missing a section declarationWCF Web.config - 无法读取配置节“system.webserver”,因为它缺少节声明
【发布时间】:2013-01-10 22:49:48
【问题描述】:

我使用的是 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>

它在 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 元素“编译”具有无效的子元素“身份验证”。预期的可能元素列表:“程序集、buildProviders、codeSubDirectories、expressionBuilders、folderLevelBuildProviders”。 p:\jcp\WCF1\WCF1\Web.config 5 5 WCF1

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

【问题讨论】:

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


    【解决方案1】:

    我也有这个拼写错误,花了我几次才发现我错过了环境中的“n”,值得将整个文件放在 VS proj 中进行测试

    【讨论】:

      【解决方案2】:

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

      1. Web.config 区分大小写。您需要将文本用驼峰式大小写(例如system.webServertargetFrameworksystem.serviceModel。)
      2. system.web.authenticationsystem.web.compilation 的同级,而不是它的子级。

      【讨论】:

      • 谢谢。尝试了这些并没有帮助。其他一些帖子建议我需要对 .NET 版本中的 system.config 文件进行手动更改。如果我想不通,看起来像是另一个 MS 重新启动或重建。另外,看来我在 IIS 7.5
      • 我现在得到这个:无法读取配置部分“System.ServiceModel”,因为它缺少部分声明
      • XML 很挑剔。 System.ServiceModel 不起作用,但 system.serviceModel 应该。当我提到 camel-casing 时,我应该更具体一些:它必须是第一个单词小写,但其他单词大写的那种。
      • 哇。我从代码项目中获取了那个代码,它都是小写的。似乎该服务已经启动,尽管我现在使用 JQuery 和提供的脚本来使用它时遇到了问题。感谢您抽出宝贵时间!
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-16
      • 2016-11-03
      • 2011-09-16
      • 2013-12-02
      • 1970-01-01
      相关资源
      最近更新 更多