In production, I have the Application_Error event handled in Global.asax to log (and email me) details of any uncaught exceptions that sneak through:
void Application_Error(object sender, EventArgs e) // code simplified a bit for SO
{
Exception ex = Server.GetLastError();
MyTools.LogError("Global.asax::Application_Error", "An unhandled exception occurred", ex);
}
The error messages themselves, however are usually useless; there is a stack trace, but with no line numbers and often no reference to any of my own code, only .net framework (BCL) methods. Sometimes there is a hint as to the page name at least, but that's about as good as it gets.
Example:
Exception of type 'System.Web.HttpUnhandledException' was thrown.
The remote host closed the connection. The error code is 0x80072746.
System.Web
Boolean HandleError(System.Exception)
at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.aRealPageName_aspx.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
So any idea how I can get global.asax to give me more useful error info?
I know I could put a try-catch into the code if there was a way to tell where to put it, but there isn't.
If your production server doesn't have pdb files it will not give you line numbers. Copy your pdb files along with your dlls to get more info.
User contributions licensed under CC BY-SA 3.0