T
tshad
I have an Application_Error function in my Global.asax function that works
fine until I try to access my Session variables.
I am emailing the results to myself whenever I get an error and would like
to get the list of the users Session Variables there were there at the time
of the error. But if I add the following line:
MyMessage.Body &= "Session Variable" & session("JobTitle") & vbCrLf
it goes back to the MS error page instead of my error page
(/PageError.aspx). If I don't have that line, I get my error page.
What is causing the problem and how can I get an the session variables?
Here is the Application_Error function:
Sub Application_Error(Sender As Object, E as EventArgs)
Dim LastException as String = Context.Error.ToString()
Dim exception As Exception = Server.GetLastError()
ExceptionLogger.Log(exception)
Dim MyMessage as New MailMessage
MyMessage.To = "(e-mail address removed)"
MyMessage.From = "(e-mail address removed)"
MyMessage.Subject = "Unhandled ASP.Net Error"
MyMessage.Body = vbCrLf & vbCrLf & "An Error was Generated on " & now &
vbCrLf & vbCrLf & _
"To see a list of Errors:
HTTP:\\www.staff.com\ad\showExceptions.aspx" & vbCrLf & vbCrLf & _
"Page: " & HTTPContext.Current.Request.Url.ToString()
& vbCrLf & vbCrLf
While Not exception Is Nothing
MyMessage.Body &= "Source: " & exception.Source & vbCrLf & _
"Message: " & exception.Message & vbCrLf & _
"Stack Trace: " & vbCrLf & exception.StackTrace &
vbCrLf & vbCrLf
exception = exception.InnerException
End While
MyMessage.Body &= "Session Variable" & session("JobTitle") & vbCrLf
SmtpMail.SmtpServer = Application("MailServer")
SmtpMail.Send(MyMessage)
Context.ClearError()
response.Redirect("/PageError.aspx")
End Sub
Thanks,
Tom
fine until I try to access my Session variables.
I am emailing the results to myself whenever I get an error and would like
to get the list of the users Session Variables there were there at the time
of the error. But if I add the following line:
MyMessage.Body &= "Session Variable" & session("JobTitle") & vbCrLf
it goes back to the MS error page instead of my error page
(/PageError.aspx). If I don't have that line, I get my error page.
What is causing the problem and how can I get an the session variables?
Here is the Application_Error function:
Sub Application_Error(Sender As Object, E as EventArgs)
Dim LastException as String = Context.Error.ToString()
Dim exception As Exception = Server.GetLastError()
ExceptionLogger.Log(exception)
Dim MyMessage as New MailMessage
MyMessage.To = "(e-mail address removed)"
MyMessage.From = "(e-mail address removed)"
MyMessage.Subject = "Unhandled ASP.Net Error"
MyMessage.Body = vbCrLf & vbCrLf & "An Error was Generated on " & now &
vbCrLf & vbCrLf & _
"To see a list of Errors:
HTTP:\\www.staff.com\ad\showExceptions.aspx" & vbCrLf & vbCrLf & _
"Page: " & HTTPContext.Current.Request.Url.ToString()
& vbCrLf & vbCrLf
While Not exception Is Nothing
MyMessage.Body &= "Source: " & exception.Source & vbCrLf & _
"Message: " & exception.Message & vbCrLf & _
"Stack Trace: " & vbCrLf & exception.StackTrace &
vbCrLf & vbCrLf
exception = exception.InnerException
End While
MyMessage.Body &= "Session Variable" & session("JobTitle") & vbCrLf
SmtpMail.SmtpServer = Application("MailServer")
SmtpMail.Send(MyMessage)
Context.ClearError()
response.Redirect("/PageError.aspx")
End Sub
Thanks,
Tom