How do I setup custom error for my ASP.net application?

ASP.net has its own built-in error handling.  To set up custom error handling for your ASP.net application, you will need to modify your web.config file.

As an example, if you want to redirect all 404 errors to error404.aspx, 500 errors to error500.aspx, and all other errors to error.htm, you would update the customErrors element in your web.config as follow :

 

<CONFIGURATION>
<SYSTEM.WEB>
<CUSTOMERRORS defaultRedirect="~/errors/error.aspx" mode="On" />
<ERROR redirect="~/errors/error400.aspx" statusCode="404" />
<ERROR redirect="~/errors/error500.aspx" statusCode="500" />
SYSTEM.WEB
>
CONFIGURATION>

 

CustomErrors is set to Off by default on all our servers.  If you do not customize the custom error element in the web.config file, the default ASP.net error (with debug information) will be displayed.

For more information about this custom error customize, please refer following site :
- http://aspnetresources.com/articles/CustomErrorPages.aspx

  • 10 Users Found This Useful
Was this answer helpful?

Related Articles

I get an error 'Server.CreateObject Failed' when I try to use CDONTs. What can I do?

CDONTs is no longer supported on Windows 2003 server.  Microsoft introduced CDO back several...

Do you allow custom COM components?

Yes, we do allow Custom Components and we have to charge setup fee for your COM Components...

ASP to MSSQL connection

Before you can access your MS-SQL Server database from your ASP code , you need to connect to it...

How do I send email from ASP using SMTP Authentication?

Please note that our mail server is configured with Authentication. Below is the code snippet...

After I configure the custom error setting in the control panel, I still get the generic error page?

Custom error setting is a web server setting that sets your website Error Pages, but you can...