Application_OnError Global Server.GetLastError = No Info

  • Thread starter Richard Coltrane
  • Start date
R

Richard Coltrane

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
 
M

marss

Richard said:
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
 
R

Richard Coltrane

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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top