Difference between Application_error and web.config?

Posted on 2004-11-18
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


    Author Comment

    Wow ...yep that explains everything cool!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    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…
    Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video discusses moving either the default database or any database to a new volume.

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now