Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Application_OnError Global Server.GetLastError = No Info

Reply
Thread Tools

Application_OnError Global Server.GetLastError = No Info

 
 
Richard Coltrane
Guest
Posts: n/a
 
      01-09-2007
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(Http Context context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.pages_crmad_aspx.ProcessRequest(HttpContext context)
at
System.Web.HttpApplication.CallHandlerExecutionSte p.System.Web.HttpApplication.IExecutionStep.Execut e()
at System.Web.HttpApplication.ExecuteStep(IExecutionS tep 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


 
Reply With Quote
 
 
 
 
marss
Guest
Posts: n/a
 
      01-09-2007

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(Http Context context)
> at System.Web.UI.Page.ProcessRequest(HttpContext context)
> at ASP.pages_crmad_aspx.ProcessRequest(HttpContext context)
> at
> System.Web.HttpApplication.CallHandlerExecutionSte p.System.Web.HttpApplication.IExecutionStep.Execut e()
> at System.Web.HttpApplication.ExecuteStep(IExecutionS tep 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/mi...5bb3e52a214209

 
Reply With Quote
 
 
 
 
Richard Coltrane
Guest
Posts: n/a
 
      01-10-2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
>
> 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(Http Context context)
>> at System.Web.UI.Page.ProcessRequest(HttpContext context)
>> at ASP.pages_crmad_aspx.ProcessRequest(HttpContext context)
>> at
>> System.Web.HttpApplication.CallHandlerExecutionSte p.System.Web.HttpApplication.IExecutionStep.Execut e()
>> at System.Web.HttpApplication.ExecuteStep(IExecutionS tep 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/mi...5bb3e52a214209
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing Session variables in Application_OnError in the Global.asax file shark_bait ASP .Net 0 07-17-2006 06:15 AM
WSE 2.0 and Global.asax Application_OnError seanmccormick1@hotmail.com ASP .Net Web Services 0 06-09-2006 03:41 PM
Application_OnError loop with custom object =?Utf-8?B?TWFydHkgVS4=?= ASP .Net 1 09-23-2004 05:47 PM
Application_OnError in IIS 6 Problem! Steve Taylor ASP .Net 4 09-15-2004 06:42 PM
Getting the aspx page an error occured on in Application_OnError Sam-I-Am ASP .Net 3 06-09-2004 11:36 PM



Advertisments