C
Corey B
I have added code to my Application_Error sub in Global.ASAX so that
whenever an error occurs in my ASP.NET application - it sends me an
email with the error information. However the information that I am
receiving doesn't have everything I would like. It doesn't give the
exact line of code and the exact place where the error occurred. Can
anyone help me with the code? I would like it to send me the same type
of information that you would see on the screen when an error occurs.
Here is the code that I am using in my Application_Error sub: (VB)
******************************
Dim ex As Exception = Server.GetLastError.GetBaseException
Dim strMessage As String
strMessage = "MESSAGE: " & ex.Message & vbCrLf & _
"SOURCE: " & ex.Source & vbCrLf & _
"STACKTRACE: " & ex.StackTrace & vbCrLf & _
"TARGETSITE: " & ex.TargetSite.ToString & vbCrLf & _
"REMOTEIP: " & Request.UserHostAddress
******************************
Then it emails me the strMessage string. An example of the email that
I receive is below:
******************************
MESSAGE: Object reference not set to an instance of an object.
SOURCE: MyApp
STACKTRACE: at MyApp.testPage.Page_Load(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain()
TARGETSITE: Void Page_Load(System.Object, System.EventArgs)
REMOTEIP: 127.0.0.1
******************************
The stacktrace is kind of helpful but it doesn't point me to a
particular line of code like a normal error message that you would see
on screen does.
Thanks,
Corey
whenever an error occurs in my ASP.NET application - it sends me an
email with the error information. However the information that I am
receiving doesn't have everything I would like. It doesn't give the
exact line of code and the exact place where the error occurred. Can
anyone help me with the code? I would like it to send me the same type
of information that you would see on the screen when an error occurs.
Here is the code that I am using in my Application_Error sub: (VB)
******************************
Dim ex As Exception = Server.GetLastError.GetBaseException
Dim strMessage As String
strMessage = "MESSAGE: " & ex.Message & vbCrLf & _
"SOURCE: " & ex.Source & vbCrLf & _
"STACKTRACE: " & ex.StackTrace & vbCrLf & _
"TARGETSITE: " & ex.TargetSite.ToString & vbCrLf & _
"REMOTEIP: " & Request.UserHostAddress
******************************
Then it emails me the strMessage string. An example of the email that
I receive is below:
******************************
MESSAGE: Object reference not set to an instance of an object.
SOURCE: MyApp
STACKTRACE: at MyApp.testPage.Page_Load(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain()
TARGETSITE: Void Page_Load(System.Object, System.EventArgs)
REMOTEIP: 127.0.0.1
******************************
The stacktrace is kind of helpful but it doesn't point me to a
particular line of code like a normal error message that you would see
on screen does.
Thanks,
Corey