Application_OnError Global Server.GetLastError = No Info

Discussion in 'ASP .Net' started by Richard Coltrane, Jan 9, 2007.

  1. Hi there,

    Ive just implemented some application level exception handling in ASP.Net
    2.0. I deliberately set up a null reference error in my code to see how this
    would be handled.
    Sure enough the applicationOnError code runs in Global.asax and hands it off
    to my custom error page but theres no info in the exception returned by
    Server.Getlasterror.

    The type of this exception is just HttpUnhandledException (which is obvious,
    thats why Im catching it at the global level). I was under the impression i
    would get a reference to the original NullRefException via GetBaseException
    but this is empty? This from my immediate window:

    ?Server.GetLastError
    {"Exception of type 'System.Web.HttpUnhandledException' was thrown."}
    System.Web.HttpUnhandledException: {"Exception of type
    'System.Web.HttpUnhandledException' was thrown."}
    Data: {System.Collections.ListDictionaryInternal}
    HelpLink: Nothing
    InnerException: {"Object reference not set to an instance of an object."}
    Message: "Exception of type 'System.Web.HttpUnhandledException' was thrown."
    Source: "System.Web"
    StackTrace: " at System.Web.UI.Page.HandleError(Exception e)
    at System.Web.UI.Page.ProcessRequestMain(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint,
    Boolean includeStagesAfterAsyncPoint)
    at System.Web.UI.Page.ProcessRequest()
    at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
    at System.Web.UI.Page.ProcessRequest(HttpContext context)
    at ASP.pages_crmad_aspx.ProcessRequest(HttpContext context)
    at
    System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
    completedSynchronously)"
    TargetSite: {System.Reflection.RuntimeMethodInfo}

    So now i have a catch all last resort and redirect in the case of a bug in
    my code. Thats more tidy for the user...but what am i supposed to use for
    diagnostic info?
    I thought this was the major reason for
    Server.GetLastError.GetBaseException? All its telling me is what i can infer
    simply from the fact that this code runs...i.e an unhandled error has
    occured.

    Thanks

    Richard
     
    Richard Coltrane, Jan 9, 2007
    #1
    1. Advertising

  2. Richard Coltrane

    marss Guest

    Richard Coltrane wrote:
    > Hi there,
    >
    > Ive just implemented some application level exception handling in ASP.Net
    > 2.0. I deliberately set up a null reference error in my code to see how this
    > would be handled.
    > Sure enough the applicationOnError code runs in Global.asax and hands it off
    > to my custom error page but theres no info in the exception returned by
    > Server.Getlasterror.
    >
    > The type of this exception is just HttpUnhandledException (which is obvious,
    > thats why Im catching it at the global level). I was under the impression i
    > would get a reference to the original NullRefException via GetBaseException
    > but this is empty? This from my immediate window:
    >
    > ?Server.GetLastError
    > {"Exception of type 'System.Web.HttpUnhandledException' was thrown."}
    > System.Web.HttpUnhandledException: {"Exception of type
    > 'System.Web.HttpUnhandledException' was thrown."}
    > Data: {System.Collections.ListDictionaryInternal}
    > HelpLink: Nothing
    > InnerException: {"Object reference not set to an instance of an object."}
    > Message: "Exception of type 'System.Web.HttpUnhandledException' was thrown."
    > Source: "System.Web"
    > StackTrace: " at System.Web.UI.Page.HandleError(Exception e)
    > at System.Web.UI.Page.ProcessRequestMain(Boolean
    > includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    > at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint,
    > Boolean includeStagesAfterAsyncPoint)
    > at System.Web.UI.Page.ProcessRequest()
    > at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
    > at System.Web.UI.Page.ProcessRequest(HttpContext context)
    > at ASP.pages_crmad_aspx.ProcessRequest(HttpContext context)
    > at
    > System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    > at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
    > completedSynchronously)"
    > TargetSite: {System.Reflection.RuntimeMethodInfo}
    >
    > So now i have a catch all last resort and redirect in the case of a bug in
    > my code. Thats more tidy for the user...but what am i supposed to use for
    > diagnostic info?
    > I thought this was the major reason for
    > Server.GetLastError.GetBaseException? All its telling me is what i can infer
    > simply from the fact that this code runs...i.e an unhandled error has
    > occured.
    >
    > Thanks
    >
    > Richard


    Read this topic, maybe it will be helpfull.
    http://groups.google.com.ua/group/m...3e52a214209?lnk=st&q=&rnum=5#8f5bb3e52a214209
     
    marss, Jan 9, 2007
    #2
    1. Advertising

  3. Hi there,

    Ok this is where Im must confess myself to be a total spaz.

    As i said i was deliberately throwing a "NullReferenceException" so when the
    wrapping exception (HttpUnhandledException) displays
    InnerException: {"Object reference not set to an instance of an object."}.
    This does not mean that the innerexception is null but rather that it holds
    an instance of an inner exception whose message says "Object reference not
    set to an instance of an object."

    Its even in the immediate window print out i listed below. Sheeze. Like i
    sad Im a total spaz.
    In my defence (my ego needs an excuse no matter how lame) i was working all
    day with learning Enterprise Library 2.0 so i was a little tired... but this
    morning this was very obvious to me. Even i do better after a reboot. ;)

    And then from there i transferred to my custom error page where your
    suggestion about IIS/ASP.net pipelines marss was most helpful.

    Thanks alot

    Richard


    "marss" <> wrote in message
    news:...
    >
    > Richard Coltrane wrote:
    >> Hi there,
    >>
    >> Ive just implemented some application level exception handling in ASP.Net
    >> 2.0. I deliberately set up a null reference error in my code to see how
    >> this
    >> would be handled.
    >> Sure enough the applicationOnError code runs in Global.asax and hands it
    >> off
    >> to my custom error page but theres no info in the exception returned by
    >> Server.Getlasterror.
    >>
    >> The type of this exception is just HttpUnhandledException (which is
    >> obvious,
    >> thats why Im catching it at the global level). I was under the impression
    >> i
    >> would get a reference to the original NullRefException via
    >> GetBaseException
    >> but this is empty? This from my immediate window:
    >>
    >> ?Server.GetLastError
    >> {"Exception of type 'System.Web.HttpUnhandledException' was thrown."}
    >> System.Web.HttpUnhandledException: {"Exception of type
    >> 'System.Web.HttpUnhandledException' was thrown."}
    >> Data: {System.Collections.ListDictionaryInternal}
    >> HelpLink: Nothing
    >> InnerException: {"Object reference not set to an instance of an object."}
    >> Message: "Exception of type 'System.Web.HttpUnhandledException' was
    >> thrown."
    >> Source: "System.Web"
    >> StackTrace: " at System.Web.UI.Page.HandleError(Exception e)
    >> at System.Web.UI.Page.ProcessRequestMain(Boolean
    >> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    >> at System.Web.UI.Page.ProcessRequest(Boolean
    >> includeStagesBeforeAsyncPoint,
    >> Boolean includeStagesAfterAsyncPoint)
    >> at System.Web.UI.Page.ProcessRequest()
    >> at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
    >> at System.Web.UI.Page.ProcessRequest(HttpContext context)
    >> at ASP.pages_crmad_aspx.ProcessRequest(HttpContext context)
    >> at
    >> System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    >> at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
    >> completedSynchronously)"
    >> TargetSite: {System.Reflection.RuntimeMethodInfo}
    >>
    >> So now i have a catch all last resort and redirect in the case of a bug
    >> in
    >> my code. Thats more tidy for the user...but what am i supposed to use for
    >> diagnostic info?
    >> I thought this was the major reason for
    >> Server.GetLastError.GetBaseException? All its telling me is what i can
    >> infer
    >> simply from the fact that this code runs...i.e an unhandled error has
    >> occured.
    >>
    >> Thanks
    >>
    >> Richard

    >
    > Read this topic, maybe it will be helpfull.
    > http://groups.google.com.ua/group/m...3e52a214209?lnk=st&q=&rnum=5#8f5bb3e52a214209
    >
     
    Richard Coltrane, Jan 10, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sam-I-Am
    Replies:
    3
    Views:
    1,549
    Sam-I-Am
    Jun 10, 2004
  2. Steve Taylor

    Application_OnError in IIS 6 Problem!

    Steve Taylor, Sep 15, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    438
    Scott Allen
    Sep 15, 2004
  3. =?Utf-8?B?TWFydHkgVS4=?=

    Application_OnError loop with custom object

    =?Utf-8?B?TWFydHkgVS4=?=, Sep 23, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    466
    William F. Robertson, Jr.
    Sep 23, 2004
  4. shark_bait
    Replies:
    0
    Views:
    887
    shark_bait
    Jul 17, 2006
  5. WSE 2.0 and Global.asax Application_OnError

    , Jun 9, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    145
Loading...

Share This Page