Difference between Application_error and web.config?

Posted on 2004-11-18
Medium Priority
Last Modified: 2008-02-01

I am trying to implement some error checking, well a global error handler really.

I have opted out of Page_error and have been looking at 2 other ways either using

1. the web.config and insert a RedirectURL in CustomErrors
2. Using application_error of global.asx

I was after some comments and confirmation of what I think I have found.

1. Using the web.config, basically transfers to a default url that i specify, problem with this is the URL is displayed in IE/Opera etc.. so its possible to bookmark it. And i don't want people to bookmark an error.aspx page
2. To get the error and display something on the Redirected url then i use Server.GetLastError for example?
3. I presume once i arrive in the RedirectedURL for the customerrors then I have to clear the error, jsut wondering why this is?

Then i looked at the Application_Error which technically as far as i can see is similar, I can catch the errors here and then do a Server.Transfer rather a Response.redirect and the URL is left alone i.e. it still displays the page where the error happened, so the user wouldn't be able to Bookmark the error.aspx page. Once I have done a server.transfer to the new page and i arrive in the new page (.aspx) then I can again use the Server.GetLastError to find out what the last error was a give a nicely formattted error page?

I was reading somewhere that I have to CLEAR the error once I arrive in the new page, is this correct? Why?

Does anyone know what the PROS and CONS are of using either of the above??

Also if I arrive in Applicatiion_error and I can recover the problem then I presume I can clear the error and server.transfer back to the original webform??

AND if I use both a Application_Error and a Customerrros RedirectURL (in web.config), are they both executed, Application_error FIRST and then the customerror redirectURL?

I know if i use a Page_Error and an application_Error then the page_error is executed and not the application_error.

Just a little confused on what to do, any advise or comments that anyone can offer would be really great.


Question by:ianinspain
LVL 28

Accepted Solution

mmarinov earned 2000 total points
ID: 12613318

Author Comment

ID: 12613401
Wow ...yep that explains everything cool!

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month13 days, 18 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question