我使用此代码进行注销
public ActionResult LogOff()
{
FormsAuthentication.SignOut();
// Drop all the information held in the session
Session.Clear();
Session.Abandon();
// clear authentication cookie
HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, "");
cookie1.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie1);
// clear session cookie
HttpCookie cookie2 = new HttpCookie("ASP.NET_SessionId", "");
cookie2.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie2);
foreach (var cookie in Request.Cookies.AllKeys)
{
Request.Cookies.Remove(cookie);
}
return RedirectToAction("Index", "Home");
}
并且它在本地工作正常,但是当我在服务器中发布我的应用程序时,即使用户已经注销,如果用户单击浏览器的Back
按钮,页面仍会显示。
答案 0 :(得分:0)