我在用户注销时删除cookie时遇到一些麻烦.
我正在学习MVC Asp.Net,我已经创建了默认的MVC5应用程序.我已注册并使用帐户登录,一切正常.但是当我点击注销它正在工作时,它会将我重定向到主页,但它不会删除cookie.
我正在使用此扩展程序"编辑此Cookie" 检查Cookie .
首先我登录然后使用EditThisCookie扩展名复制cookie,然后注销并删除cookie.现在,当我将复制的cookie粘贴到EditTshiCookie扩展中并刷新页面时,它会使用相同的帐户登录.Cookie不会被删除.
LogOff方法
// POST: /Account/LogOff
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult LogOff()
{
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
return RedirectToAction("Index", "Home");
}
Run Code Online (Sandbox Code Playgroud)
我从这个问题尝试了这个
Request.GetOwinContext().Authentication.SignOut();
Request.GetOwinContext().Authentication.SignOut(Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ApplicationCookie);
HttpContext.Current.GetOwinContext().Authentication.SignOut(Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ApplicationCookie);
Run Code Online (Sandbox Code Playgroud)