【发布时间】:2016-03-25 16:53:19
【问题描述】:
我正在使用 ASP.NET 身份登录的应用程序中开发注销功能。我可以成功登录,但是当我注销然后尝试再次登录时,我收到以下消息:
The provided anti-forgery token was meant for a different claims-based user than the current user.
这是我的注销代码:
public ActionResult Logout()
{
SignInManager.Logout();
return View("Index");
}
**SignInManager.cs**
public void Logout()
{
AuthenticationManager.SignOut();
}
用户按下注销按钮后,他将被带到登录屏幕。网址仍然显示“http://localhost:8544/Login/Logout”。因为我们在登录屏幕上,所以它应该只说“http://localhost:8544/Login”。
【问题讨论】:
-
我认为您可以在注销操作中使用重定向使其工作,而不是直接返回视图。
return RedirectToAction("Index");这有望正确设置所有标头和 cookie 信息。 -
就我而言,这是 EDMX 文件的一些问题。一旦我更新了所有表格,问题就消失了。
标签: asp.net asp.net-mvc