ログアウトしてログインページにリダイレクトするログアウトアクションがありますが、ログアウトせずにブラウザーを閉じ、ログアウト時に再度開くと、ログアウトアクションにアクセスせずにログインアクションに直接リダイレクトされます
[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>