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

    Hi

    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?

    Thanks,

    S
     
    Sam-I-Am, Jun 9, 2004
    #1
    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
    #2
    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
    even
    if we want to do some page level operations when the unhandled error
    occur.
    Here is a tech article discussing on the error handling in ASP.NET

    #Rich Custom Error Handling with ASP.NET
    http://msdn.microsoft.com/library/en-us/dnaspp/html/customerrors.asp?frame=t
    rue

    Hope also helps. Thanks.


    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Get Preview at ASP.NET whidbey
    http://msdn.microsoft.com/asp.net/whidbey/default.aspx
     
    Steven Cheng[MSFT], Jun 9, 2004
    #3
  4. Sam-I-Am

    Sam-I-Am Guest

    Thanks for the reply

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

    Thanks,

    S
     
    Sam-I-Am, Jun 10, 2004
    #4
    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.