Click here to Skip to main content
16,018,534 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to implement when session timeout how to redirect to login page.
i saw in some forum's in page load event
C#
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
Updated 3-Dec-12 5:52am
v2

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
XML
<authentication mode="Forms">
      <forms loginUrl="login.aspx" defaultUrl="homePage.aspx" timeout="yourTime" name="UserLogin" path="/"/>
    </authentication>

In login.aspx.cs
C#
FormsAuthentication.RedirectFromLoginPage(username, persistent cookie?)
 
Share this answer
 
Check Session state where you want to check that user is login or not like

C#
if(!IsPostBack)
{

if(!Session["Session_name"]=null)
{

//Your code while your session is not null
}
else
{

Response.Redirect("Login_Page.aspx");
}
}
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900