Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
I want to secure code for logout when click on logout button.
 

I was try many code for logout but can't success.
In many codes after click on logout button and press beck button of browser then again go in page.
 

so please send me secure logout code...
 

 
please help me..
 
Rakesh
Posted 7-Apr-12 4:11am
Comments
digimanus at 7-Apr-12 9:19am
   
how do you know some one is logged in? How do you maintain that state?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

That is not a problem with the log out code - it is because the Back button is handled within the browser, and does not need a round-trip to the server. Since the page is already loaded, the browser just displays it from it's internal cache and doesn't do a page load at the server.
 
There isn't a whole lot you can do about it: the best approach is to open your site in a new window that doesn't have a back button. You can get that effect by setting the "toolbar" to "no" when you configure the new window.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Onclick of logout button, redirect user to logout.aspx page. Add following code in logout.aspx page.
 
protected void Page_Load(object sender, EventArgs e)
    {
        Session.Abandon();
        
        Response.Redirect(clsCommon.value("login.aspx?mode=logout");
    }
  Permalink  
Comments
BalaMahesh at 18-Oct-12 0:51am
   
here what is clscommon
Mukund Thakker at 18-Oct-12 1:00am
   
You can write directly
Response.Redirect("login.aspx?mode=logout");
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

protected void LogIn_Click(object sender, EventArgs e)
{
Session.Add("uname", txtUname .Text );
Session.Add("pass", txtPass .Text );
DataTable dt = BusinessLayer.GetData("select * from tblLogin where uid='" + txtUname .Text + "' and Upwd='" + txtPass .Text + "'");
if (dt.Rows.Count == 0)
{
//lblmessage.Text = "Invalid username or password";
Response.Write("<script language=javascript>alert('You Are Invalid User')</script>");
Response .Redirect ("Home.aspx");
}
}
 

protected void lnkbtnlogout_Click(object sender, EventArgs e)
   {
       Session.Abandon();
       Session.Clear();
       Response.Redirect("~/Default.aspx");
   }
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

  Permalink  
Comments
Trak4Net at 9-Jul-12 14:27pm
   
The cache setting is what will resolve the issue. As stated it is the browser reloading the cached content. Setting the cache expiration or dissallowing the cache will be what you want to do. You do not have to do it in a master page you can do it in a per page situation so if only an admin page is what you want to keep from caching you can set the cache settings for that page.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

You can use ASP.NET Login control if you are using Forms authentication that will take care of Logout
 
http://www.c-sharpcorner.com/uploadfile/raj1979/login-control-in-Asp-Net-3-5/[^]
  Permalink  
Comments
nitesh chaudhary at 5-Mar-13 8:29am
   
protected void lnkbtnlogout_Click(object sender, EventArgs e)
{
Session.Abandon();
Session.Clear();
Response.Redirect("~/Default.aspx");
}
 

i am using this code its working but i am pressing backspace ...going to previous page

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

  Print Answers RSS
0 OriginalGriff 587
1 Sergey Alexandrovich Kryukov 544
2 Maciej Los 325
3 DamithSL 223
4 Mathew Soji 195
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,712
2 DamithSL 5,461
3 Manas Bhardwaj 4,916
4 Maciej Los 4,475


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 27 Feb 2013
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