【发布时间】:2013-03-14 16:25:20
【问题描述】:
我正在使用以下代码行在使用asp.net MVC4. 注销后禁用浏览器后退按钮问题
[OutputCache(NoStore = false, Duration = 0, VaryByParam = "None")]
public ActionResult Logout()
{
try
{
if (Session["username"] != null)
{
Session.Abandon();
Session.Clear();
Session.RemoveAll();
Session["username"] = null;
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();
return RedirectToAction("Index", "AdminPanel");
}
return RedirectToAction("Error", "Home");
}
catch (Exception e)
{
return RedirectToAction("Error", "Home");
}
}
但是,这段代码有一个问题,假设我有三页第一页是登录页(Index.cshtml),第二页成功登录页(home.cshtml),第三页是关于页(about.cshtml),现在我登录然后现在我在 about.cshtml 的第三页上移动,然后我从 about.cshtml 页面注销,它会将我重定向到 home.cshtml 页面,它会将我重定向到 login.cshtml 页面。现在,如果我单击浏览器后退按钮,然后再次将我重定向到 about.cshtml 页面,但用户无法更改或添加任何内容。
所以让我知道有没有合适的代码或方法来解决这个问题。
【问题讨论】:
标签: asp.net-mvc-4 browser-cache back-button