Retrieve SessionID in Global asax

  • Thread starter Thread starter kurt sune
  • Start date Start date
K

kurt sune

Does anyone know how to retrieve the current sessionId in
Global.asax.ApplicationError?

/k
 
Came up with this:

In global.asax:
Dim s As String =
Request.Cookies.Item("ASP.NET_SessionId").Value
If Not s Is Nothing Then Application(s) = "the error text"
Response.Redirect("GenericErrorPage.aspx")

In the error page:

Dim s As String = String.Empty
s = HttpContext.Current.Session.SessionID
Dim ee As String = Application(s).ToString
'display ee on the page

What do you think? A viable solution?

The article you mentioned says that the sessionid is unique between
restarts.

/m
 
What do you think? A viable solution?
No.

The article you mentioned says that the sessionid is unique between
restarts.

Er, no it doesn't. Try reading it again - specifically, the bit which says:

"if the Web server is restarted, some SessionID values may be the same as
those generated before the server was stopped."
 
Mark Rae said:

Why, please?
Er, no it doesn't. Try reading it again - specifically, the bit which says:

"if the Web server is restarted, some SessionID values may be the same as
those generated before the server was stopped."

Yes, and when restarted all session and application data gets viped out
and the user has to connect again.
 
"Object reference not set to an instance of an object."

I suspect that global asax is global and instance specific data is thus not
reachable from it.
(they were in VS 2003, but something has changed...)
 
Yes, and when restarted all session and application data gets viped out
and the user has to connect again.

And, in doing so, may acquire the SessionID from a different user's session
before the server was restarted i.e. WON'T BE UNIQUE!!!

I really don't know how else to explain this...
 
Back
Top