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?


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” />


This section of the web.config has to be placed in the following structure:
<configuration> Element
  system.web Element (ASP.NET Settings Schema)
You can obtain more information on how to set this up by visiting the MSDN website. Here is an example obtained from there:



<customErrors defaultRedirect=”GenericError.htm”


<error statusCode=”500″





You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: