Home > DotNet > How to show error page in ASP.Net

How to show error page in ASP.Net

Handle custom errors in ASP.Net

Once the ASP.Net application is ready to launh to customers, there is no need to show the error details in to the web page when any errors occurred. In this scenario we can show our customised page with details like “Server is busy now please after some time” to the customer. At the same time we can store error details to database or txt file for future reference for developers. For customise errors in the ASP.Net we need to do some settings in the web.config file.

 Settings on web.config to show error page 

<customErrors mode="On" defaultRedirect="error.aspx">
<error statusCode="404" redirect="404Error.aspx"/>

The above code should be placed in the web.config file for handling custom errors (mode=”On”). Also we can handling particular erros with error code with appropriate error page. In above mentioned code, if a user request a page that is not in the server, 404 error is occurred then page is automatically direct to 404Error.aspx. If any other errors occurred, it will show web page error.aspx. In the same way we can handle any type of error with the status code, with the appropriate web page.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: