Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
Hi
 
I have developed a small web based school management system.In that a logout button is placed in the masterpage .in that logout buttons click i have set a session variable and redirect the page to logout.aspx page.In that page in the page load i have cleared the session and redirect to login page .But logout is happening when i doing something in the system without actually logging out.code sample is given below:
 
  protected void logoutbtn_Click(object sender, EventArgs e)
    {
        Session["logout"] = "true";
 
        Response.Redirect("logout.aspx");
    }
 

protected void Page_Load(object sender, EventArgs e)
   {
       if(!IsPostBack)
       {
           if (Session["logout"] != null)
           {
 
               Session.Clear();
               Response.Redirect("Login.aspx");
           }
 
       }
   }
 
waiting for reply
Posted 28-Jan-13 2:06am
Edited 28-Jan-13 2:11am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

if (Session["logout"] != null)
{
  if (Session["logout"] == "true")
  {
    Session.Clear();
    Response.Redirect("Login.aspx");
  }
}
 
Edit:
I had the same problem when developing my own app.
If you are interested in how I solved it you can view the article here.[^]
  Permalink  
v2
Comments
meenavinaymenon at 8-Feb-13 8:10am
   
The problem still persists..please help me.
Marco Bertschi at 8-Feb-13 8:12am
   
Maybe the solution 2 by sisir pato helps you?
meenavinaymenon at 14-Feb-13 1:49am
   
I tried the second solution,Still same problem please help me to recover from this.
Marco Bertschi at 14-Feb-13 4:26am
   
Mh... I faced the same issue when developing my own app (it is using master pages too).
I wrote my solution down to an article because I thought that there are other people suffering from the same problem:
http://www.codeproject.com/Articles/535520/Basic-Login-functionalities-for-ASP-Net-4-0
meenavinaymenon at 18-Mar-13 7:58am
   
Thanku Marco
Marco Bertschi at 18-Mar-13 9:25am
   
I assume that the article helped you?
 
cheers,
Marco Bertschi
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

HI,
 
On logout button click clear the session values using any one of the following code:
 
Session.Clear();
 
or
 
            Session.Abandon();
 
Thanks
  Permalink  

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



Advertise | Privacy | Mobile
Web04 | 2.8.140709.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid