Click here to Skip to main content
15,883,869 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Good Day ALL

I have tried something and i am not sure what is the problem.

i have inherited the an app. So i want to add the custom Error Handling. I know there are two methods i can do this.

1) Web Config


So i started with the web config just to see how it will look and i accessed the page that normally gives an Exception. so basically i have a page gives a

500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.

So now , if there is an Error i want it to go to that Error Page. In the web config i have the Following

<customErrors defaultRedirect="content/ErrorPages/SupportError.aspx" mode="On">
  <error statusCode="404" redirect="content/ErrorPages/SupportError.aspx" />
  <error statusCode="400" redirect="content/ErrorPages/SupportError.aspx" />
  <error statusCode="500" redirect="content/ErrorPages/SupportError.aspx" />

This means that when this kind of Errors occur it should redirect to that page. All these pages are contents of the Master page including the Error page. But this Error Persist it does not show me the Error page. Even if i try to see if it goes to "Application_Error" in the Global.asa nothing goes there.

So i have also tried the second option. so i turned the web config part
"off" and i trapped this in the global.asa like this

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)

    'Response.Redirect("~/Content/ErrorPages/SupportError.aspx", False)
End Sub

but still nothing happens


If you are using try catch in your code ,add the following statement
throw ex;

to the catch block
if you suppress the exception you will not be redirected hence simply throw the exception.
Share this answer
Vimalsoft(Pty) Ltd 16-May-12 13:32pm    
this makes sense, let me try it and i will give feedback
VJ Reddy 18-May-12 0:26am    
Good suggestion. 5!
This problem occurs because the handler mapping for the requested resource points to a .dll file that cannot process the request.

To resolve this problem:
Edit the handler mapping for the requested resource to point to the .dll file that can process the request. To do this, follow these steps:

1. Click Start, click Run, type inetmgr.exe, and then click OK.
2. In IIS Manager, expand server name, expand Web sites, and then click the Web site that you want to modify.
3. In Features view, double-click Handler Mappings.
4. Right-click the script mapping that you want to edit, and then click Edit.
5. In the Edit Script Map dialog box, type the appropriate executable file in the Executable box, and then click OK.

See details here: Microsoft Support: Error message when you visit a Web site that is hosted on IIS 7.0: "HTTP Error 500.0 – Internal Server Error"[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900