您好,我是第一次在 MVC 中开发解决方案,所以我面临一个大问题,
当我从我的应用程序(mvc razor web 应用程序)注销时,它会显示登录页面,但是如果我按下浏览器后退按钮,它会显示最后一个屏幕,我不想要这个,我希望如果我按下后退按钮,它仍然显示相同的登录页面。
这是我的注销代码
public ActionResult Logout()
{
Session.Clear();
Session.Abandon();
Session.RemoveAll();
FormsAuthentication.SignOut();
this.Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
this.Response.Cache.SetCacheability(HttpCacheability.NoCache);
this.Response.Cache.SetNoStore();
return RedirectToAction("Login");
}
最佳答案
不久前我遇到了这个问题,禁用整个应用程序的缓存解决了我的问题,只需将这些行添加到 Global.asax.cs
文件
protected void Application_BeginRequest()
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();
}
希望这可以帮助。
关于asp.net-mvc - 注销后,如果浏览器后退按钮按下,则返回上一个屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19315742/