What Page threw the exception

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
 
T

Tom Kiefer

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
 
S

Steven Cheng[MSFT]

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.)
 
S

Steven Cheng[MSFT]

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

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top