0
當我點擊返回按鈕的瀏覽器兩次其採取我訪問頁面..第一次,當我點擊返回後註銷它需要我登錄頁面中的預期,但當我再次點擊回到它帶我到訪問過的頁面..我如何阻止?任何想法 這裏是我的代碼:單擊瀏覽器後退按鈕後,可以在註銷後查看訪問的頁面。我如何避免?
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;
}
}
}
代碼與註銷的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);
}
}
謝謝你的回覆......這是不工作...當我點擊瀏覽器後退按鈕兩次。 – keerthi 2014-09-24 20:40:37
您使用哪種瀏覽器?我知道可能會與舊版瀏覽器發生衝突。 – user1666620 2014-09-24 20:50:49
IE.11 ...第一次工作正常,另一次後退單擊我訪問頁面 – keerthi 2014-09-24 20:53:55