Script(s)

what I learn is what u c

Asp.net Detecting Session timeout and redirection

leave a comment »

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

Advertisements

Written by gchandra

August 28, 2007 at 10:12 am

Posted in Asp.Net

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: