0

I have a asp.net web application login page which has buil-in Authentication of asp.net and login.aspx page created by Login control of asp.net. Now i have a problem in logout.

When user pressed "Logout" the link is redirected to "Login.aspx" page. But, when the user press "Back" button from the browser the user "Login"to the page to the application which i want to avoid and it must ask to enter Login Credentials.

Help Appreciated..! Thanks in Advace..!

SHEKHAR SHETE
  • 5,964
  • 15
  • 85
  • 143

3 Answers3

2

you can try

   protected void btnLogout_Click(object sender, EventArgs e)
    {
        Session.RemoveAll();
        Session.Abandon();

        Response.Redirect("LoginPage.aspx");
    }
BreakHead
  • 10,480
  • 36
  • 112
  • 165
  • thanks for reply..! but, this but does not work...When he press the "Back" button of Browser again he logged in to the web page. – SHEKHAR SHETE Mar 19 '12 at 08:35
0

If you are using MasterPage then in the Code Behind of your MasterPage, you can do this

Response.ExpiresAbsolute = DateTime.Now.AddDays(-1d);
Response.Expires = -1500;
Response.CacheControl = "no-cache";

Also do not forget to clear the Session while Logging off.

Sergey
  • 1,608
  • 1
  • 27
  • 40
vpv
  • 920
  • 2
  • 20
  • 46
0

Use the following code:

Session.RemoveAll();
 FormsAuthentication.SignOut(); 

FormsAuthentication.RedirectToLoginPage();
ankit rajput
  • 182
  • 2
  • 5