G
Guest
For one reason or another I am unable to access Session contents in my
asp.net application via the global.asax's Application_Error event. I can
pull this exact code snippet below out of global.asax and place it in a
normal page (or class file that doesn't inherit from system.web.ui.page) and
things work fine:
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim currentContext As System.Web.HttpContext =
System.Web.HttpContext.Current
Dim sessionInfo As System.Web.SessionState.HttpSessionState =
currentContext.Session
Response.Write("try to get session count")
Response.Write("<br />")
Response.Write(sessionInfo Is Nothing) ' always returns True
Response.Write("<br />")
Response.Write(sessionInfo.Contents.Count) ' always throws a Null
Reference exception, so would sessionInfo("mySessionVar")
Response.End()
End Sub
Session state is currently being held In Process (default), and it doesn't
matter whether this application has any Session variables established or not
- I get the same result.
Can someone shed some light / provide some working code?
asp.net application via the global.asax's Application_Error event. I can
pull this exact code snippet below out of global.asax and place it in a
normal page (or class file that doesn't inherit from system.web.ui.page) and
things work fine:
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim currentContext As System.Web.HttpContext =
System.Web.HttpContext.Current
Dim sessionInfo As System.Web.SessionState.HttpSessionState =
currentContext.Session
Response.Write("try to get session count")
Response.Write("<br />")
Response.Write(sessionInfo Is Nothing) ' always returns True
Response.Write("<br />")
Response.Write(sessionInfo.Contents.Count) ' always throws a Null
Reference exception, so would sessionInfo("mySessionVar")
Response.End()
End Sub
Session state is currently being held In Process (default), and it doesn't
matter whether this application has any Session variables established or not
- I get the same result.
Can someone shed some light / provide some working code?