What Page threw the exception

  • Thread starter Thread starter Gary
  • Start date Start date
G

Gary

I'm in the application_error event. I want to know which aspx experienced
the exception. Is there any easy way?
Thanks,
G
 
Server.GetLastError() will return the last exception thrown, if that helps
at all.

Have you tried somethign like:

Exception ex = Server.GetLastError();
strSource = ex.Source;

strSource should then include the name of the object that threw the
exception

- Tom Kiefer
thogek @ earthlink . net
 
Hi Gary,


Thanks for posting in the community! My name is Steven, and I'll be
assisting you on this issue.
From your description, you catched some unhandlered exceptions in the
Global object's "Application_Error" event, and you're wanting to get the
source infos of the certain exception,yes?
If there is anything I misunderstood, please feel free to let me know.

Based on my research, I think Tom Kiefer's suggest that use
"Server.GetLastError();" to retrieve the last thrown exception is quite
correct. You can then get many infos from the Exception object such as:
Exception.HelpLink ---------Gets or sets a link to the help file associated
with this exception.
Exception.InnerException -------Gets the Exception instance that caused the
current exception.
Exception.Message ---------Gets a message that describes the current
exception.
Exception.Source ----------Gets or sets the name of the
application or the object that causes the error
Exception.StackTrace ----------Gets a string representation of the frames
on the call stack at the time the current exception was thrown.
......

For more detailed info on the System.Exception class, you may view the
reference in MSDN:
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemExceptionClass
Topic.asp?frame=true

Also, here are some tech articles on handle the application level or page
level exceptions in ASP.NET:
#Handling Application-Level Errors
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vbcode/h
tml/vbtskcodeexamplehandlingapplicationlevelerror.asp

#Handling Page-Level Errors
http://msdn.microsoft.com/library/en-us/dv_vbCode/html/vbtskCodeExampleHandl
ingPageLevelErrors.asp?frame=true

I belive they're also helpful to you.


Please check out the above items. If you have any further questions, please
feel free to post here.



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.)
 
Hi Gary,


Have you had a chance to check out my suggestion or have you resolved the
problem? If you need any assistance, please feel free to post here.


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.)
 
Back
Top