Click here to Skip to main content
12,508,014 members (53,640 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
plz help me with Session..

i have gone through all the code on internet.. and even try every thing nothing working..
plz help me step by step creating and executing..



i appreciate the help.. i have also gone through all these link below ...
i want it automatically to redirect to login page.. not by clicking the button when the session ends..

if any one know what exactly the code should be written in "Session_end --> Global.aspx" guess this will solve my problem and redirect to login page automatically when session time is out..
Posted 30-Sep-12 7:35am
Updated 1-Oct-12 23:09pm
v2
Comments
Sandeep Mewara 30-Sep-12 14:01pm
   
Do you have FormsAuthentication implemented in your application? You will have different answer based on it.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

void Session_Start(object sender, EventArgs e)
{
Response.Redirect("LoginPage.aspx");
}

Under Global.asax file
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

One more...way of doing it

protected void Page_Init(object sender, EventArgs e)

{

if (Context.Session != null)

{

if (Session.IsNewSession)


HttpCookie objCookie= Request.Cookies["ASP.NET_SessionId"];

if (objCookie!= null)

{

string objCookie= objCookie.Value;

if (objCookie!= string.Empty)

{

// Here we go...it's a time out or new session.......

Response.Redirect("Login.aspx");

}

}

}

}

}
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

protected void Page_Load(object sender, EventArgs e)
   {
           if(Session["UserName"]==null)
           {
               Response.Redirect("Login.aspx");
           }
   }
  Permalink  

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


Advertise | Privacy | Mobile
Web02 | 2.8.160927.1 | Last Updated 11 Jun 2014
Copyright © CodeProject, 1999-2016
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