Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
how to implement when session timeout how to redirect to login page.
i saw in some forum's in page load event
Response.AppendHeader("Refresh", Convert.ToString((Session.Timeout * 60) - 3) + "; URL=Login.aspx");
 
but when i refresh the page it is not redirecting the page to login page when session expires
 
please help me
 
thank you.
Posted 3-Dec-12 5:53am
Edited 3-Dec-12 6:52am
ridoy53.3K
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

http://csharpdotnetfreak.blogspot.com/2008/11/detecting-session-timeout-and-redirect.html[^]
OR
http://stackoverflow.com/questions/484964/asp-net-push-redirect-on-session-timeout[^]
OR
In Web.config
<authentication mode="Forms">
      <forms loginUrl="login.aspx" defaultUrl="homePage.aspx" timeout="yourTime" name="UserLogin" path="/"/>
    </authentication>
In login.aspx.cs
FormsAuthentication.RedirectFromLoginPage(username, persistent cookie?)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Check Session state where you want to check that user is login or not like
 
if(!IsPostBack)
{
 
if(!Session["Session_name"]=null)
{
 
//Your code while your session is not null
}
else
{
 
Response.Redirect("Login_Page.aspx");
}
}
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 /\jmot 210
1 Richard Deeming 195
2 Richard MacCutchan 190
3 Zoltán Zörgő 175
4 Peter Leow 170
0 Sergey Alexandrovich Kryukov 9,328
1 OriginalGriff 6,831
2 Peter Leow 4,477
3 Zoltán Zörgő 3,984
4 Richard MacCutchan 2,832


Advertise | Privacy | Mobile
Web02 | 2.8.150129.1 | Last Updated 3 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100