G
Guest
I want to get the file name, line number etc. in error handling code in an
asp.net application. I know how to trap errors in the Global.asax and I read
that you can use the stack frame from the System.Diagnostics namespace to get
line numbers provided you release in debug mode but when I use the code below
I merely get the line number, file name etc. of the Global.asax page, not the
page that produced the error. Any way to do this?
protected void Application_Error(Object sender, EventArgs e)
{
string errorLine;
string fileName;
string functionName;
StackTrace st=new StackTrace (0,true);
StackFrame sf=new StackFrame ();
sf=st.GetFrame (0);
fileName = sf.GetFileName ();
errorLine = sf.GetFileLineNumber().ToString();
functionName = sf.GetMethod().ToString();
}
asp.net application. I know how to trap errors in the Global.asax and I read
that you can use the stack frame from the System.Diagnostics namespace to get
line numbers provided you release in debug mode but when I use the code below
I merely get the line number, file name etc. of the Global.asax page, not the
page that produced the error. Any way to do this?
protected void Application_Error(Object sender, EventArgs e)
{
string errorLine;
string fileName;
string functionName;
StackTrace st=new StackTrace (0,true);
StackFrame sf=new StackFrame ();
sf=st.GetFrame (0);
fileName = sf.GetFileName ();
errorLine = sf.GetFileLineNumber().ToString();
functionName = sf.GetMethod().ToString();
}