Application_Error method Vs. Custom Error pages

I’m going to answer two FAQ about Application_Error method and Custom error pages.

1. If we have defined a custom error pages for our application, will the Application_Error method get fired?

Of course it will. Application_Error method in the Global.asax file will get fired whenever an unhandled exception occurs. Application_Error method will invoke every time an unhandled exception occurs regardless of whether you've declared a custom error page or not. After that method being executed, it will display the custom error page.

2. If we are doing a Response.Redirect or Server.Transfer inside the Application_Error method, then what will happen? Will the custom error page get displayed after that?

No it will not. Then the application will be redirected to the page which we've defined in the Application_Error method. It will not go to the custom error page since we are overriding the redirect page in global.asax.


Anonymous said...

Grateful to check out your website, I seem to be ahead to more excellent content and I believe we all really like to thank for so many excellent content, weblog to discuss with us.
android app making software

Rehashi ma said...

I actually enjoyed reading through this posting.Many thanks

Custom Application Development