Click here to Skip to main content
12,943,528 members (55,475 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
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
Updated 3-Dec-12 5:52am
ridoy59.2K
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
Top Experts
Last 24hrsThis month
OriginalGriff 4,643
CHill60 2,970
Maciej Los 2,348
Jochen Arndt 1,900
ppolymorphe 1,765


Advertise | Privacy | Mobile
Web02 | 2.8.170518.1 | Last Updated 3 Dec 2012
Copyright © CodeProject, 1999-2017
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