I once saw that was possible to do something like adding a key in the web.config file to redirect to a default error page everytime a unhandled exception is found.
Is it possible? how?
I once saw that was possible to do something like adding a key in the web.config file to redirect to a default error page everytime a unhandled exception is found.
Is it possible? how?
Add a CustomErrors section to your web.config.
<customErrors defaultRedirect="ErrorPage.aspx" mode="RemoteOnly" />
Yes the customErrors
section of the web.config.
<customErrors defaultRedirect="~/GenericError.aspx" mode="On" />
This will redirect your users to what defaultRedirect
(URL) when they encounter an error.
You can also specify where they go based on the HTTP response code
<customErrors defaultRedirect="~/GenericError.aspx" mode="On">
<error statusCode="500" redirect="~/Error.aspx"/>
<error statusCode="404" redirect="~/NotFound.aspx"/>
</customErrors>
Here is the documentation.
<customErrors defaultRedirect="~/serverErrorPage.aspx" mode="On" redirectMode="ResponseRewrite"/>
It's not suitable for real use prior to .NET3.5 service pack 1, as until then the redirectMode attribute wasn't there and it would always act with the default value "ResponseRedirect"
which would redirect to the error page instead of showing it directly; so instead of giving an error response it would "successfully" redirect to another page, and then that would return the error!