¿Cómo puedo detectar una mejor ASP.NET sesión caducada?
Pregunta
Necesito detectar cuando una sesión ha caducado en mi Visuial aplicación web Básica.Esto es lo que estoy 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
devuelve HttpContext.Current.Session.IsNewSession
Esto parece funcionar bien para Internet Explorer, pero parece fallar con Firefox.
Solución
Intente lo siguiente
If Session("whatever") IsNot Nothing Then
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow