The configuration section 'httpErrors' cannot be read because it is missing a section declaration

吃可爱长大的小学妹 提交于 2020-01-06 07:38:07

问题


I am trying to configure a custom error page for the 403 Forbidden response in my WebApi application by adapting Example of Configuration for <httpErrors>. I added <httpErrors> to my Web.config but I'm getting HTTP Error 500.19 and The configuration section 'httpErrors' cannot be read because it is missing a section declaration.

How can I fix it?


My code:

<system.web>
  ....
  <httpErrors errorMode="Custom">
    <remove statusCode="403" subStatusCode='-1' />
    <error statusCode="403" path="/forbidden.html" prefixLanguageFilePath="" responseMode="ExecuteURL"  />
  </httpErrors>
</system.web>

Screenshot of the error:


回答1:


Copied from the comment.

Such error messages are clear, which requires you to go to IIS reference documentation to learn the actual sections.

https://docs.microsoft.com/en-us/iis/configuration/system.webserver/httperrors/

Then it is obvious that httpErrors is a section under system.webServer, not system.web.



来源:https://stackoverflow.com/questions/54291482/the-configuration-section-httperrors-cannot-be-read-because-it-is-missing-a-se

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!