[英]C# ASP.NET MVC Back button issue after logout
I am working on a logout method for an MVC application and I ran into a problem. 我正在为MVC应用程序开发注销方法,但遇到了问题。 Every time I logout, the application checks the user authentication and returns them to the login page.
每次注销时,应用程序都会检查用户身份验证,并将其返回到登录页面。
Logout method: 登出方法:
[HttpGet]
[CustomAuthorize]
public ActionResult Logout()
{
//Response.Cache.SetExpires(DateTime.Now);
FormsAuthentication.SignOut();
Session.Clear();
Session.Abandon();
Session.RemoveAll();
return RedirectToAction("Index", "Home");
}
The pages used after loging in all have the [CustomAuthorize] attribute. 登录后使用的所有页面均具有[CustomAuthorize]属性。
Using MS Edge browser, if I click the Back button, the program goes through the CustomAuthorize method and if the user is logged out, it just returns them to the Login page as intended. 使用MS Edge浏览器,如果我单击“上一步”按钮,程序将通过CustomAuthorize方法,如果用户已注销,则仅将其按预期返回到“登录”页面。
However, if I use any other browser (Chrome, Firefox), pressing the Back button just goes back to the previous page where I pressed the Logout button without even going through the CustomAuthorize to check the Authorization. 但是,如果我使用任何其他浏览器(Chrome,Firefox),则按“后退”按钮仅返回上一页面,在此我按了“注销”按钮,甚至没有通过CustomAuthorize来检查授权。
What could be the cause for this and what could be a possible solution to resolve this issue? 这可能是什么原因,以及解决该问题的可能解决方案是什么?
If any more information is needed, just let me know. 如果需要更多信息,请告诉我。
Thank you. 谢谢。
Justas 就像
you need to disable caching globally 您需要全局禁用缓存
protected void Application_BeginRequest()
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.