【发布时间】:2014-09-25 04:14:33
【问题描述】:
当我两次单击浏览器的后退按钮时,它会将我带到访问过的页面.. 第一次当我在注销后单击返回时,它会按预期将我带到登录页面,但是当我再次单击返回时它会带我访问页面.. 我该如何阻止呢?任何想法 这是我的代码:
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;
}
}
}
注销链接按钮中的代码:
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);
}
}
【问题讨论】: