views:

127

answers:

2

If I have a customErrors section in my Web.config that says to redirect to Error.html, then putting code in the Application_Error method in the Global.asax to redirect to Error.html is redundant is it not? Technically, I could bypass the Web.config by redirecting to a different page in the Application_Error method if I wanted to, but since I don't want to go to a separate page I don't think I need the code.

+1  A: 

Per this article:

http://support.microsoft.com/kb/306355

If you have the CustomErrors redirect in your web.config, you don't need to do a redirect in the Global.Asax's Application _Error event. You are right, this would be redundant.

However, I would test it just to be sure. I've always just used the Global.asax and redirected from there. I've never used the customErrors error page feature.

David Stratton
Thanks for the reply. I'm playing around with some of the error handling in ASP.NET, and I notice if I do a Response.Redirect(url, False) in the Global.asax, the redirect doesn't actually happen. I end up with the Server Error HTTP 500 ASP.NET message. I know you can use True in that method to end the process and go straight to the HTTP 302 redirect, but do you have any insight as to why the redirect doesn't occur unless you end the processing?
Ek0nomik
+2  A: 

Yes it is redundant to do it both ways if you have a single error page.

Ben Robinson