问题
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