How to Get Exception StackTrace in Application_Error ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Cramer

    How to Get Exception StackTrace in Application_Error ?

    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.



  • S.M. Altaf [MVP]

    #2
    Re: How to Get Exception StackTrace in Application_Err or ?

    Hi Cramer,

    Are you looking for System.Diagnost ics.StackFrame?
    Provides information about a StackFrame, which represents a function call on the call stack for the current thread.


    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:OVNfo4uqIH A.2208@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.
    >
    >

    Comment

    • Peter Bromberg [C# MVP]

      #3
      Re: How to Get Exception StackTrace in Application_Err or ?

      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:OVNfo4uqIH A.2208@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.
      >
      >

      Comment

      Working...