Problem Redirecting to the Custom Error Page

Posted by Vuyiswamb under ASP.NET on 5/16/2012 | Points: 10 | Views : 7932 | Status : [Member] [MVP] [Administrator] | Replies : 5
Good Day ALL

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

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

1) Web Config

2)Global.asa

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" />
</customErrors>


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)
Server.Transfer("~/Content/ErrorPages/SupportError.aspx")

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


but still nothing happens

THanks

Thank you for posting at Dotnetfunda
[Administrator]



Responses

Posted by: Akiii on: 5/16/2012 [Member] Bronze | Points: 25

Up
0
Down
Sir, I am using the custom error handling block in web.config file and it is working fine. I think this is the best method to handle the errors others its not a good solution to write error handling code in each and every page.

Have you tested in localhost ?
Is it showing the same problem in the localhost ?


Thanks and Regards
Akiii

Vuyiswamb, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 5/16/2012 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
hi Akiii

Sometimes you would like to send an email and get the Error that was produced ,so the global.asa option is good for that as i said i tried both of them but i failed miserably.

Thanks


Thank you for posting at Dotnetfunda
[Administrator]

Vuyiswamb, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Akiii on: 5/16/2012 [Member] Bronze | Points: 25

Up
0
Down
What error code is thrown when an application error is encountered in the global.asax file ?


Thanks and regards
Akiii

Vuyiswamb, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 5/16/2012 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
hi Akiii

i dont get an Error , The problem is that if there is a 500 Exception, the Error Page does not Appear .

Thank you for posting at Dotnetfunda
[Administrator]

Vuyiswamb, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Akiii on: 5/16/2012 [Member] Bronze | Points: 25

Up
0
Down
Its a strange situation. I have encountered a page while i was reading, please go through it :-

http://www.checkupdown.com/status/E500.html



Regards
Akiii

Vuyiswamb, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response