注销后,如果我单击后退按钮,我想保留在登录页面中……但是当我单击后退按钮时,此代码将不起作用,它将重定向到上一页。可以帮助我。
public virtual ActionResult Logout()
{
FormsAuth.SignOut();
ActionResult homeAction = MVC.Account.Login();
string logoffUrl = Url.Action(homeAction);
string[] myCookies = Request.Cookies.AllKeys;
foreach (string cookie in myCookies)
{
Request.Cookies[cookie].Expires = DateTime.Now.AddDays(-1);
Response.Cookies[cookie].Expires = DateTime.Now.AddDays(-1);
Response.Cookies.Add(Response.Cookies[cookie]);
Request.Cookies.Add(Request.Cookies[cookie]);
}
HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
HttpContext.Response.Cache.SetValidUntilExpires(false);
HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Response.Cache.SetNoStore();
return RedirectToAction(homeAction);
}
}