473,666 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Get Exception StackTrace in Application_Err or ?

I'm developing a new ASP.NET 3.5 app and I have an http module hooked up to
Application_Err or that logs [otherwise unhandled] detailed exception data.

When it parses and evaluates unhandled exceptions, it "sees" all exceptions
as type "System.Web.Htt pUnhandledExcep tion", with the message:
"Exception of type 'System.Web.Htt pUnhandledExcep tion' 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_Err or, how can I get the same
detailed information that ASP.NET places into the informative "error message
page", rather than simply getting the HttpUnhandledEx ception exception?

Thanks.

Jun 27 '08 #1
2 4710
Hi Cramer,

Are you looking for System.Diagnost ics.StackFrame?
http://msdn.microsoft.com/en-us/libr...tackframe.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]


"Cramer" <A@B.comwrote in message
news:OV******** ******@TK2MSFTN GP04.phx.gbl...
I'm developing a new ASP.NET 3.5 app and I have an http module hooked up
to Application_Err or that logs [otherwise unhandled] detailed exception
data.

When it parses and evaluates unhandled exceptions, it "sees" all
exceptions as type "System.Web.Htt pUnhandledExcep tion", with the message:
"Exception of type 'System.Web.Htt pUnhandledExcep tion' 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_Err or, how can I get the same
detailed information that ASP.NET places into the informative "error
message page", rather than simply getting the HttpUnhandledEx ception
exception?

Thanks.

Jun 27 '08 #2
I don't know what your HttpModule does or how it works. But if you want to
get the "real" exception in Application_Err or, it would be:

Exception ex =
Server.GetLastE rror().GetBaseE xception();

--Peter
"Cramer" <A@B.comwrote in message
news:OV******** ******@TK2MSFTN GP04.phx.gbl...
I'm developing a new ASP.NET 3.5 app and I have an http module hooked up
to Application_Err or that logs [otherwise unhandled] detailed exception
data.

When it parses and evaluates unhandled exceptions, it "sees" all
exceptions as type "System.Web.Htt pUnhandledExcep tion", with the message:
"Exception of type 'System.Web.Htt pUnhandledExcep tion' 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_Err or, how can I get the same
detailed information that ASP.NET places into the informative "error
message page", rather than simply getting the HttpUnhandledEx ception
exception?

Thanks.

Jun 27 '08 #3

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

Similar topics

3
1434
by: Gary | last post by:
I'm in the application_error event. I want to know which aspx experienced the exception. Is there any easy way? Thanks, G
1
4314
by: Eric Gibson | last post by:
Hey, I want to be able to get a sensible exception message that I can actually use to fix my code using asp.net... I was able to set up the Application_Error event, and email exceptions to myself, but they only include "Message" and "StackTrace"... Every email I've gotten includes no information about the error in a way that would help me fix it. I've tried using "GetBaseException", and "InnerException"... But all I get are emails...
6
1267
by: Todd Bright | last post by:
Is there a way to get to the last exception in .Net from outside a catch block? I've inherited someone else's ASP.Net app that's having problems. He is calling a method to log his errors but is only passing his custom error messages so there is no way to know what is really happening. What I would like to do is to access the last exception that occurred from the LogError() function rather than have to modify all of the places that it is...
3
2442
by: John Holgerson | last post by:
Hi, is it possible to get informations about the exception that occured in that method?? (global.asax) protected void Application_Error(Object sender, System.EventArgs e) { } thanks for help John
2
2673
by: Brad Baker | last post by:
I'm trying to create a custom ASP.NET custom error page however I am having some problems. Here is what I have done: 1) I've created a page called default.aspx with the following code to stimulate an error:
2
2405
by: chris | last post by:
I am sure I am overlooking something simple, but here goes. In the global.asax file I have some code in the Application_Error method that reads information out of the current exception and emails it to me. I want to see what the parameter values are for the method throwing the exception. I am using reflection to get the parameter metadata, but this does not do me much good. Exception ex = Server.GetLastError().GetBaseException(); ...
5
1657
by: David Thielen | last post by:
Hi; I have added the code to my code behinds of: private void Page_Error(object sender, EventArgs e) { throw Server.GetLastError(); } But I now have the problem that the call stack I get is to Page_Error. I need the call stack of the exception that got me to this point. How can I get
9
2534
by: AG | last post by:
I occassionally get the following exception from an ASP.NET 2.0 Web Application running on a shared web host. I have no way of knowing what the actual request page was as it never happens when I visit the site. The exception is trapped in the Application_Error event of global.asax and emailed to me. The only encryption in the app is the connectionStrings section of web.config.
0
1282
by: fergallydon | last post by:
Hi, I'm trying to implement some centralised exception handling and logging in the Application_Error() event of global.asax. If the code that generates the exception is not inside a try-catch block then Application_Error() runs correctly. However, I want to use a try-catch-finally. I want to do some stuff in the catch block before re-throwing the exception. In this case the exception is correctly caught by the catch but even though I...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8866
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7385
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1772
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.