ASP.NET has its own built-in error handling. To set up custom error handling for your ASP.NET application, you need to modify your web.config file.
For 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 should update the customErrors element in your web.config as follows:
<customErrors mode="On" defaultRedirect="error.htm">
<error statusCode="500" redirect="error500.aspx"/>
<error statusCode="404" redirect="error404.aspx"/>
CustomErrors are 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.
If you run into problems using this code, we suggest you to get the answer from related community forum. Technical support cannot assist with specific coding related issues.