Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / April 2008

Tip: Looking for answers? Try searching our database.

How to Get Exception StackTrace in Application_Error ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cramer - 30 Apr 2008 19:15 GMT
I'm developing a new ASP.NET 3.5 app and I have an http module hooked up to
Application_Error that logs [otherwise unhandled] detailed exception data.

When it parses and evaluates unhandled exceptions, it "sees" all exceptions
as type "System.Web.HttpUnhandledException", with the message:
"Exception of type 'System.Web.HttpUnhandledException' was thrown."

At the same time and for the exact same exception, on my development
computer, ASP.NET shows a very informative error message, with the text,
"Server Error in  '/MyAppNameHere' Application" -- and that is followed by
the specific exception message (e.g., "Divide by zero error
encountered.") -- and that is followed by the specific line that choked,
incliding the .cs source code line number and .cs file path -- followed by
the stack trace that shows the actual sequence of method calls that lead to
the method that threw the exception.

My question:
In my http module hooked up to Application_Error, how can I get the same
detailed information that ASP.NET places into the informative "error message
page", rather than simply getting the HttpUnhandledException exception?

Thanks.
S.M. Altaf [MVP] - 30 Apr 2008 19:33 GMT
Hi Cramer,

Are you looking for System.Diagnostics.StackFrame?
http://msdn.microsoft.com/en-us/library/system.diagnostics.stackframe.aspx

This should let you look at the kind of information you've specified in your
question.  Please note, though, that using StackFrame can seriously slow
down your application, so use it if you really, really, really, really,
really need to.

-S.M. Altaf [MVP]

> I'm developing a new ASP.NET 3.5 app and I have an http module hooked up
> to Application_Error that logs [otherwise unhandled] detailed exception
[quoted text clipped - 20 lines]
>
> Thanks.
Peter Bromberg [C# MVP] - 30 Apr 2008 21:22 GMT
I don't know what your HttpModule does or how it works. But if you want to
get the "real" exception in Application_Error, it would be:

 Exception ex =
Server.GetLastError().GetBaseException();

--Peter
> I'm developing a new ASP.NET 3.5 app and I have an http module hooked up
> to Application_Error that logs [otherwise unhandled] detailed exception
[quoted text clipped - 20 lines]
>
> Thanks.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.