Reputation: 139
I have web application and I make SignIn module, now when I logout and click back button in browser then I see view which should be accessible only after sing in. How can I prevent this?
I use identity for authorization. In IE it's working but in Firefox and Chrome not working. Code for logout:
[HttpPost]
[ValidateAntiForgeryToken]
public virtual ActionResult SignOut()
{
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
return RedirectToAction(MVC.Login.Login.SignIn());
}
Upvotes: 1
Views: 535
Reputation: 1774
Decorate your controller/action method with Authorize
attribute like below
[HttpPost]
[Authorize]
[ValidateAntiForgeryToken]
public virtual ActionResult SignOut()
{
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
return RedirectToAction(MVC.Login.Login.SignIn());
}
Upvotes: 1