Hi Scott,
Welcome to the ASP.NET newsgroup.
For the component classes in the System.Diagnostics namespace, they provide
the function to inspect the current executing thread's code path and
structure. However, for your scenario, the when you use the
System.Diagnostics components in Application_Error event, it can only
display execution info of the current executiion funciton( the
Application_Error event handler) rather than the unhandled exception
because the exception has occuried before the application_Error event be
fired.
To get the information for the unhandled exception, I think you should use
the Server.GetLastError() method to get the exception object reference and
them get the detailed information of the exception through the Exception
object's properties. For example:
void Application_Error(object sender, EventArgs e)
{
Exception ex = Server.GetLastError();
Context.Items.Add("current_exception", Server.GetLastError());
Server.Transfer("~/MyCustomErrorPage.aspx");
}
then, in my custom error page, we can printout the unhandled exception info:
protected void Page_Load(object sender, EventArgs e)
{
Exception ex = Context.Items["current_exception"] as Exception;
if (ex != null)
{
Response.Write("<br/>-----------------------------");
Response.Write("<br/>Source: " + ex.Source);
Response.Write("<br/>-----------------------------");
Response.Write("<br/>StackTrace: " + ex.StackTrace);
Response.Write("<br/>-----------------------------");
}
}
Hope this helps.
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.)