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 4:53am
Edited 3-Dec-12 5:52am
ridoy51.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 OriginalGriff 510
1 Prakriti Goyal 255
2 Yogesh Kumar Tyagi 224
3 Maciej Los 195
4 CPallini 180
0 OriginalGriff 6,632
1 Sergey Alexandrovich Kryukov 5,429
2 Maciej Los 3,474
3 Peter Leow 3,309
4 DamithSL 2,495


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 3 Dec 2012
Copyright © CodeProject, 1999-2014
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