ASP.NET has a custom error message feature that sometimes does not work. A default generated error page is displayed even if your web.config file includes this configuration:
<customerrors defaultredirect="InternalError.htm" mode="On" />
Microsoft documentation explains it very well, except this detail that I ran into and want to explain here: a custom error page specified in defaultRedirect must be available to unauthenticated uses, otherwise a default generated error page is displayed if an error happens before a user is authenticated. I add the following section to web.config to make it work
web.config snippet:
...
<system.web>
...
<customErrors defaultRedirect="InternalError.htm" mode="On" />
...
</system.web >
...
<!--
this is necessary to allow user to see error page even if they are not logged in
for example this happens when database server is unavailable
-->
<location path="InternalError.htm" >
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment