ASP.NET MVC 4 で独自のログイン/ログアウト モジュールに取り組んでおり、ログアウト アクションの結果でセッションをクリアし、次のコードを使用してキャッシュを保存していません。
[HttpGet]
public ActionResult Login()
{
return View();
}
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "None")]
[HttpPost]
public ActionResult Login(Models.User user)
{
if (ModelState.IsValid)
{
if (user.IsValid(user.UserName, user.Password))
{
FormsAuthentication.SetAuthCookie(user.UserName, user.RememberMe);
return RedirectToAction("Index", "Admin");
}
else
{
ModelState.AddModelError("", "Login data is incorrect!");
}
}
return View(user);
}
public ActionResult Logout()
{
FormsAuthentication.SignOut();
Session.Clear();
Session.Abandon();
Session.RemoveAll();
return RedirectToAction("Index", "Home");
}
ホームインデックスコントローラー
[Authorize]
public ActionResult Index()
{
return View();
}
レイアウト cshtml
@if (Request.IsAuthenticated)
{
<strong>@Html.Encode(User.Identity.Name)</strong>
@Html.ActionLink("Sign Out", "Logout", "User")
@Html.ActionLink("Grid", "Index", "Admin")
}
else
{
@Html.ActionLink("Sign In", "Login", "User")
}
フォーム認証を使用しており、すべて正常に動作しますが、ページからログアウトした後も、戻るボタンをクリックして保護されたページにアクセスできます。
どこを間違えているか分かるかな