Question

Je dois détecter l'expiration d'une session dans mon application Web Visuial Basic.C'est ce que j'utilise...

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 Retour HttpContext.Current.Session.IsNewSession

Cela semble bien fonctionner pour Internet Explorer, mais semble échouer avec Firefox.

Était-ce utile?

La solution

Essayez ce qui suit

If Session("whatever") IsNot Nothing Then
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top