【问题标题】:The configuration section 'system.webserver' cannot be read because it is missing a section declaration无法读取配置部分“system.webserver”,因为它缺少部分声明
【发布时间】:2020-06-11 08:27:43
【问题描述】:

Web.config 文件代码:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.web>
      <system.webServer>
        <httpErrors errorMode="DetailedLocalOnly">
        </httpErrors>
      </system.webServer>
      <httpCookies httpOnlyCookies="true" />
      <trace enabled="true" >
      </trace>
      <customErrors mode="RemoteOnly" />
      <compilation debug="false" />
      <authentication>
          <forms cookieless="UseCookies" requireSSL="false" protection="Validation" />
      </authentication>
      <sessionState cookieless="UseUri" mode="StateServer" />s
    </system.web>
</configuration>

在 Powershell 中运行 Get-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/' -filter "system.webServer/httpErrors" -name "errorMode" 命令时出现错误消息:

Get-WebConfigurationProperty:文件名:\?\C:\inetpub\wwwroot\web.config

行号:4

错误:无法读取配置节“system.webserver”,因为它缺少节声明

【问题讨论】:

    标签: xml iis


    【解决方案1】:

    我认为根本原因是您将&lt;system.webserver&gt; 放入&lt;system.web&gt;。请修改这些属性,因为 system.webserver 和 system.web 在同一级别。

    请像这样修改配置

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    
          <system.webServer>
            <httpErrors errorMode="DetailedLocalOnly">
            </httpErrors>
          </system.webServer>
    
     <system.web>
          <httpCookies httpOnlyCookies="true" />
          <trace enabled="true" >
          </trace>
          <customErrors mode="RemoteOnly" />
          <compilation debug="false" />
          <authentication>
              <forms cookieless="UseCookies" requireSSL="false" protection="Validation" />
          </authentication>
          <sessionState cookieless="UseUri" mode="StateServer" />
        </system.web>
    </configuration>
    

    请记住在此处删除“s”

    【讨论】:

      猜你喜欢
      • 2011-09-16
      • 2013-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多