我在ASP.NET MVC 4中使用默认登录模块.我没有更改默认应用程序中的任何代码,而是将其托管在共享服务器上.
我使用默认登录页面登录后.我让浏览器闲置了一段时间.然后,当我尝试使用[Authorize]属性执行任何控制器操作时,显然应用程序重定向到登录页面 .
然后我尝试再次登录,当我点击登录按钮时出现错误.
The anti-forgery cookie token and form field token do not match.
Run Code Online (Sandbox Code Playgroud)

登录操作
// POST: /Account/Login
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginModel model, string returnUrl)
{
if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
{
return RedirectToLocal(returnUrl);
}
// If we got this far, something failed, redisplay form
ModelState.AddModelError("", "The user name or password provided is incorrect.");
return View(model);
}
Run Code Online (Sandbox Code Playgroud) 我有一个动作方法,我需要在单击后退按钮时执行.我之前通过在我的操作方法中禁用缓存(Response.Cache.SetCacheability(HttpCacheability.NoCache))来完成此操作.这不适用于不同的操作方法.出于某种原因,当我禁用缓存并点击后退按钮时触发我的操作方法页面过期.有关问题的任何想法?