我需要检测当一届会议已经过期,在我Visuial基本的网页应用程序。这是什么我用...

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.

有帮助吗?

解决方案

试试下面

If Session("whatever") IsNot Nothing Then
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top