473,324 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Application_OnError Global Server.GetLastError = No Info

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
Jan 9 '07 #1
2 4233

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

Jan 9 '07 #2
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" <ma***@ukr.netwrote in message
news:11**********************@51g2000cwl.googlegro 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.CallHandlerExecutionSt ep.System.Web.HttpApplication.IExecutionStep.Execu te()
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

Jan 10 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: tafs7 | last post by:
My code below is supposed to email me when an error occurs on the application, but it's not emailing anything. Am I missing something? I know the smtp servers I've tried work. I even added a...
3
by: Mike Malter | last post by:
I have a general error page that I configured in web.config as <customErrors mode="On" defaultRedirect="CRDefaultError.aspx" /> This error page comes up whenever an error occurs outside of any...
3
by: Sam-I-Am | last post by:
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? ...
1
by: Marty U. | last post by:
I have written a custom exception handler to process exceptions (send email, write to db). My code looks like such in the Global.asax Application_OnError event Exception ex =...
5
by: vbMental | last post by:
I am deep into a project and cannot get this to work correctly. I am trying to make a custom error page that will be able to know what exception occurred. I already know about the defaultRedirect...
0
by: seanmccormick1 | last post by:
We are having trouble trapping errors that occur in the WSE 2.0 code. Our error handling/logging for our web services happens in the Global.asax Application_OnError method, but it does not seem to...
2
by: Seguros Catatumbo | last post by:
Hello guys, i am trying to port my custom asp 3.0 error page to asp.net. I want to disable debugging in my asp.net projects but i want to show the users a pretty page but that page should send me...
2
by: =?Utf-8?B?Y2FzaGRlc2ttYWM=?= | last post by:
Hi, I have a web application which has an error handling layer which is performing quite well. Any exceptions caught in a try/catch block are fed to this layer and they pass the exception to...
19
by: =?Utf-8?B?anZjb2FjaDIz?= | last post by:
I've got a global.aspx file that works in my dev environment (vs 2005). When i publish the site to a windows 2000 sp4 box running IIS, the global does not seem to fire. Since it's a test server,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.