无法读取配置部分 'httpErrors',因为它缺少部分声明
The configuration section 'httpErrors' cannot be read because it is missing a section declaration
我正在尝试通过调整 在我的 WebApi 应用程序中为 403 Forbidden 响应配置自定义错误页面。我将 <httpErrors>
添加到我的 Web.config 但我得到 HTTP Error 500.19
和 The configuration section 'httpErrors' cannot be read because it is missing a section declaration
.
我该如何解决?
我的代码:
<system.web>
....
<httpErrors errorMode="Custom">
<remove statusCode="403" subStatusCode='-1' />
<error statusCode="403" path="/forbidden.html" prefixLanguageFilePath="" responseMode="ExecuteURL" />
</httpErrors>
</system.web>
错误截图:
从评论中复制。
这样的错误信息很清楚,需要你去IIS参考文档去了解具体章节。
https://docs.microsoft.com/en-us/iis/configuration/system.webserver/httperrors/
那么很明显httpErrors
是system.webServer
下的一个section,不是system.web
.
我正在尝试通过调整 在我的 WebApi 应用程序中为 403 Forbidden 响应配置自定义错误页面。我将 <httpErrors>
添加到我的 Web.config 但我得到 HTTP Error 500.19
和 The configuration section 'httpErrors' cannot be read because it is missing a section declaration
.
我该如何解决?
我的代码:
<system.web>
....
<httpErrors errorMode="Custom">
<remove statusCode="403" subStatusCode='-1' />
<error statusCode="403" path="/forbidden.html" prefixLanguageFilePath="" responseMode="ExecuteURL" />
</httpErrors>
</system.web>
错误截图:
从评论中复制。
这样的错误信息很清楚,需要你去IIS参考文档去了解具体章节。
https://docs.microsoft.com/en-us/iis/configuration/system.webserver/httperrors/
那么很明显httpErrors
是system.webServer
下的一个section,不是system.web
.