在表单模式下清除会话后,razor pagestill中的身份验证@ User.Identity.Name具有值(domaine \ username)。为什么?
Web.config:
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="30" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
IIS:
Anonymymous身份验证 - &gt;激活
表单身份验证 - &gt;激活
注销代码:
FormsAuthentication.SignOut();
Session.Abandon();
// Clear authentication cookie
HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, "");
cookie1.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie1);
// Clear session cookie
SessionStateSection sessionStateSection = (SessionStateSection)WebConfigurationManager.GetSection("system.web/sessionState");
HttpCookie cookie2 = new HttpCookie(sessionStateSection.CookieName, "");
cookie2.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie2);
return RedirectToAction("Index", "Home");