http -如何最好地检测ASP.NET过期会话?

Translate

我需要检测Visuial 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

这似乎很好IE浏览器,但似乎失败了火狐浏览器.

This question and all comments follow the "Attribution Required."

所有的回答

Translate

尝试以下

If Session("whatever") IsNot Nothing Then
来源