Can you try this and see if it makes a difference ?
Protected Sub Application_Error(sender As [Object], e As EventArgs)
' Get the information about the error
Dim ctxt As HttpContext = HttpContext.Current
Dim except As Exception = ctxt.Server.GetLastError()
Dim errorInfo As String = "<br>Offending URL: " + ctxt.Request.Url.ToString() + "<br>Source: " _
+ except.Source + "<br>Message: " + except.Message + "<br>Stack trace: " + except.StackTrace
ctxt.Response.Write(errorInfo)
' --------------------------------------------------
' To let the page finish executing we clear the error
' --------------------------------------------------
ctxt.Server.ClearError()
End Sub
--------
Next suggestion :
Without a valid session, you won't be able to store the exception information in it.
Try wrapping the statement in a conditional :
If Not HttpContext.Current.Session Is Nothing Then
Dim ctxt As HttpContext = HttpContext.Current
Dim except As Exception = ctxt.Server.GetLastError()
HttpContext.Current.Session.Add("sExample", except)
End If
That will tell you if your Session is valid.
If it is valid, you'll see the Session sExample set with the Exception info.
If it's not valid, Session sExample will be empty.
Post the code which is failing.
- Show quoted text -
Here is the code:
Sub Application_Error(ByVal sender As Object, ByVal e As
EventArgs)
' Fires when an error occurs
Dim ex As Exception = Server.GetLastError()
If Not ex.InnerException Is Nothing AndAlso TypeOf
ex.InnerException Is System.IO.FileNotFoundException Then
HttpContext.Current.Session("sExample") = "This is an
example"
End If
End Sub