Domanda

Devo rilevare quando una sessione è scaduta nella mia applicazione Web Visual Basic.Questo è quello che sto usando...

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

Nota: CurrentSession.IsNew ritorna HttpContext.Current.Session.IsNewSession

Questo sembra funzionare bene per Internet Explorer, ma sembra fallire Firefox.

È stato utile?

Soluzione

Prova quanto segue

If Session("whatever") IsNot Nothing Then
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top