How do you display custom error pages on an ASP.Net application?
How can you create custom error pages on an ASP.Net application so that you can better control the user experience when the unexpected happens?
A:
There is a configuration parameter in the Web.Config you can use to control what error pages the user sees:
<customErrors defaultRedirect=”ErrorPage.aspx” mode=”On”>
<error statusCode=”500″ redirect=”servererror.aspx” />
<error statusCode=”404″ redirect=”filenotfound.aspx” />
<error statusCode=”403″ redirect=”AccessDenied.aspx” />
</customErrors>
This section of the web.config has to be placed in the following structure:
<configuration> Element system.web Element (ASP.NET Settings Schema) <customErrors>
You can obtain more information on how to set this up by visiting the MSDN website. Here is an example obtained from there:
<configuration>
<system.web>
<customErrors defaultRedirect=”GenericError.htm”
mode=”RemoteOnly”>
<error statusCode=”500″
redirect=”InternalError.htm”/>
</customErrors>
</system.web>
</configuration>
Love
Can we use Let's Encrypt, the free and open certificate authority?
Hola! gracias por la info, me sirvió el comando sacandole el nombre del server. En mi caso, fue una migración…
Yes 3rd option helped me too. I removed the WC key Values from config file then started working.
I know this is from 2014. But really, thank you!