Asp.net Detecting Session timeout and redirection
If you are using Basepage logic its better to use this code there.
Redirection logic is written for pages with Frames or without Frames
Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs) MyBase.OnPreRender(e) If context.Session.IsNewSession = True Then Dim strCookieHeader As String = Page.Request.Headers("Cookie") If Not strCookieHeader Is Nothing Then strCookieHeader = strCookieHeader.ToLower End If 'Checking for duplicate Session. If Not strCookieHeader Is Nothing AndAlso strCookieHeader.IndexOf("asp.net_sessionid") >= 0 Then If Page.Request.IsAuthenticated = True Then System.Web.Security.FormsAuthentication.SignOut() End If 'If you want to redirect to defaultpage you can use this 'Page.Response.Redirect("default.aspx?Timeout") 'If you are using Frames then this will work. Response.Write("window.open('default.aspx?Timeout','_parent');") End If End If End Sub
Leave a comment