Debugging Dotnet Web Application

J

jpaquette

Anyone who could help with this I would greatly appreciate it. I'm
managing a dotnet website that has several persistent errors in it I'm
trying to fix. The problem is that the error trapping I have set up
does not provide me with enough useful information to find the problem
and correct it. Here is the procedure I have set up to handle errors:

protected void Application_Error(Object sender, EventArgs e){
string strError = "Error in: " + Request.Path +
"\nUrl: " + Request.RawUrl + "\n\n";

// Get the exception object for the last error message that
occured.
Exception ErrorInfo = Server.GetLastError();
strError += "Error Message: " + ErrorInfo.InnerException.Message+
"\n" + ErrorInfo.TargetSite +
"\nError Source: " + ErrorInfo.Source + "\nError Target Site: " +
ErrorInfo.TargetSite + "\n\nQueryString Data:\n-----------------\n";

// Gathering QueryString information
for (int i = 0; i < Context.Request.QueryString.Count; i++)
strError += Context.Request.QueryString.Keys + ":\t\t" +
Context.Request.QueryString + "\n";
strError += "\nPost Data:\n----------\n";

// Gathering Post Data information
for (int i = 0; i < Context.Request.Form.Count; i++)
strError += Context.Request.Form.Keys + ":\t\t" +
Context.Request.Form + "\n";
strError += "\n";
if (User.Identity.IsAuthenticated) strError += "User:\t\t" +
User.Identity.Name + "\n\n";
strError += "Exception Stack Trace:\n----------------------\n" +
Server.GetLastError().StackTrace + "\n";
StackTrace st=new StackTrace (Server.GetLastError(),true);
StackFrame sf=st.GetFrame(0);
strError += "\nLine Number:"+sf.GetFileLineNumber()+"\n";
strError += "\n\nServer Variables:\n-----------------\n";

// Gathering Server Variables information
bool SendMail=true;
for (int i = 0; i < Context.Request.ServerVariables.Count; i++)
{
strError += Context.Request.ServerVariables.Keys + ":\t\t" +
Context.Request.ServerVariables + "\n";
if(Context.Request.ServerVariables=="216.143.157.32")
SendMail=false;
}
strError += "\n
}
}
}
}
The information generated by this procedure is then emailed to me.
When I get the email this is what I find:

Error in: /Default.aspx
Url: /Default.aspx

Error Message: Object reference not set to an instance of an object.
Boolean HandleError(System.Exception)
Error Source: System.Web
Error Target Site: Boolean HandleError(System.Exception)

QueryString Data:
-----------------

Post Data:
----------

Exception Stack Trace:
----------------------
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain()
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously)

When I look at the stack trace to find the problem it looks as though
it's giving me information about the script I wrote to handle the
error, not the actual code that broke. At this point I'm not sure if I
have my error handling set up to give me the proper information. If
anyone has any ideas at all about what I can do, please let me know.
Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top