【发布时间】:2010-09-05 10:52:26
【问题描述】:
我需要在我的 Visual Basic Web 应用程序中检测会话何时过期。这就是我正在使用的......
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
注意:CurrentSession.IsNew返回HttpContext.Current.Session.IsNewSession
这对于 Internet Explorer 似乎很有效,但对于 Firefox 似乎失败了。
【问题讨论】:
-
您可以使用 Global.asax 中的 Session_End 函数吗? http://articles.techrepublic.com.com/5100-10878_11-5771721.html
-
我目前只在 global.asax 文件中使用 Application_Error 事件。也许我的会话处理也属于那里。但是,如何在请求的页面加载时使用它?