我有注销操作,可以注销并重定向到登录页面,但是当我关闭浏览器而不注销并在注销时再次打开时,它会直接重定向到登录操作而不访问注销操作
[OutputCache(NoStore=true, Duration=0)]
public ActionResult LogOut()
{
FormsAuthentication.SignOut();
Session.Abandon();
HttpContext.User = null;
HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, "");
cookie1.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie1);
HttpCookie cookie2 = new HttpCookie("ASP.NET_SessionId", "");
cookie2.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie2);
HttpCookie cookie3 = new HttpCookie("myCookie");
cookie3.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie3);
FormsAuthentication.RedirectToLoginPage();
return null;
}
这是我的 webconfig 设置
<authentication mode="Forms">
<forms loginUrl="~/Account/LoginPage"
defaultUrl="~/User/MyKids"
timeout="99999999"
slidingExpiration="true" />
</authentication>