Getting the aspx page an error occured on in Application_OnError

Discussion in 'ASP .Net' started by Sam-I-Am, Jun 9, 2004.

  1. Sam-I-Am

    Sam-I-Am Guest


    I am using the Application_OnError event to handle exceptions in a web app.
    How can I get a reference to the page the exception occurred on from within
    the Application_OnError event?


    Sam-I-Am, Jun 9, 2004
    1. Advertisements

  2. I used Page.Error event

    Dim ex As Exception = Server.GetLastError()
    and Server.ClearError() after i got all information i needed about error
    Konrad Rotuski, Jun 9, 2004
    1. Advertisements

  3. Hi Sam,

    Generally we can use the HttpContext.Current.Handler to retrieve current
    request's processing handler, for example:

    System.Web.UI.Page page = (System.Web.UI.Page)HttpContext.Current.Handler ;

    but, don't think it'll be helpful in the Application_Error event since at
    that time the current processing is throwed to application level and won't
    return to page level. I agree with Konrad that we can use the Page_Error
    if we want to do some page level operations when the unhandled error
    Here is a tech article discussing on the error handling in ASP.NET

    #Rich Custom Error Handling with ASP.NET

    Hope also helps. Thanks.


    Steven Cheng
    Microsoft Online Support

    Get Secure!
    (This posting is provided "AS IS", with no warranties, and confers no

    Get Preview at ASP.NET whidbey
    Steven Cheng[MSFT], Jun 9, 2004
  4. Sam-I-Am

    Sam-I-Am Guest

    Thanks for the reply

    I have simply used:
    string page = Context.Request.Url.ToString();


    Sam-I-Am, Jun 10, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.