when i click back button of the browser twice its taking me to visited pages.. for the first time when i click on back after log out its takes me to Login in page as expected but when i click back again its taking me to visited pages.. How do i stop that?? Any idea Here is my Code:
protected void Page_Load(object sender, EventArgs e)
{
Response.AppendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0.
Response.AppendHeader("Expires", "0");
if (!IsPostBack)
{
LoginMultiview.ActiveViewIndex = 0; ///// Login Page.
}
else
{
}
}
protected void btnsubmit_Click(object sender, EventArgs e)
{
if (AuthenticateUser(txtUserName.Text, txtPassword.Text))
{
string Username = Session["username"].ToString();
string Password = Session["password"].ToString();
if (Session["username"] != null && Session["password"] != null)
{
GetEmployeeId(Username, Password);
LoginMultiview.ActiveViewIndex = 1;
GetManagerTimeSheets();
}
else
{
Response.Redirect("Login.aspx");
LoginMultiview.ActiveViewIndex = 0;
}
}
else
{
string Username = Session["username"].ToString();
string Password = Session["password"].ToString();
if (Session["username"] != null && Session["password"] != null)
{
ddlWeeks.DataSource = GetWeeksDropdownData();
ddlWeeks.DataBind();
Response.Write("WELCOME" + " " + Username);
LoginMultiview.ActiveViewIndex = 2;
}
else
{
Response.Redirect("Login.aspx");
LoginMultiview.ActiveViewIndex = 0;
}
}
}
Code with in Logout LinkButton:
protected void LinkButton2_Click(object sender, EventArgs e)
{
Session.Clear();
Session.RemoveAll();
Session.Abandon();
if (Session["username"] == null&& Session["password"]== null)
{
Response.Redirect("Login.aspx", true);
}
}
You can add no-cache Meta HTML headers to the pages you don't want cached.
<META Http-Equiv="Cache-Control" Content="no-cache"/>
<META Http-Equiv="Pragma" Content="no-cache"/>
<META Http-Equiv="Expires" Content="0"/>
This is a similar question: How to prevent user from going back to the login-page after successful login using back button
This seems to be a good walkthrough:
http://www.codeproject.com/Tips/135121/Browser-back-button-issue-after-logout
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.