views:

1137

answers:

2

I need to detect when a session has expired in my Visuial Basic web application. This is what I'm using...

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If CurrentSession.IsNew AndAlso (Not Page.Request.Headers("Cookie") Is Nothing) AndAlso (Page.Request.Headers("Cookie").IndexOf("ASP.NET_SessionId") >= 0) Then
Response.Redirect("TimeOut.aspx")
End If

...do something...

End Sub

Note: CurrentSession.IsNew returns HttpContext.Current.Session.IsNewSession

This seems to work well for Internet Explorer, but seems to fail with Firefox.

+2  A: 

Can you work with the Session_End function in Global.asax?

http://articles.techrepublic.com.com/5100-10878_11-5771721.html

Michael Stum
I'm only currently using the Application_Error event in the global.asax file. Perhaps my session handling belongs there as well. But, how do I use that on the requested page load?
Zack Peterson
+4  A: 

If Session("whatever") IsNot Nothing Then

Shawn Simon