I have a question. I work in ASP .NET MVC 5 . I want to prevent is that , after logging out , then I click the back navigation button , I don't want to go back to the previous page . Is there anyone who can help me? I use Session Clear and Abandon methods and FormsAuthentication's SignOut method.But this not sole my problem.
Asked
Active
Viewed 4,606 times
1
-
the forms auth token is stored in cookie not in session. Try clearing the form auth cookie as mentioned here - http://stackoverflow.com/questions/412300/formsauthentication-signout-does-not-log-the-user-out – Developer Jan 12 '17 at 11:29
-
`Session.Abandon` should work correct. BUT, only when you use sessions to store data in. What method do you use to store your data? – Max Jan 12 '17 at 11:30
-
1you need to prevent browser to go back or clear history from browser cache. – Sain Pradeep Jan 12 '17 at 11:30
-
what do you use cookie within session? – Masoud Andalibi Jan 12 '17 at 11:30
-
Do you use checkauthorization – Rush.2707 Jan 12 '17 at 12:25
3 Answers
2
Should use your OutputCache action method
[OutputCache(NoStore = true, Duration = 1)]
or
Global.asax.cs you add
protected void Application_BeginRequest()
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();
}
Do session check in action method
if (Session["xxx"] == null)
{
return View("aaaa");
}

Sercan Elvanağacı
- 98
- 9
1
This happens because the browser caches the data, you have to clear the browser cache by setting some headers in the page response.
You can do that using the answer of this question How to refresh page on back button click?

Haitham Shaddad
- 4,336
- 2
- 14
- 19
1
[See the Image]
1)sign out the user
2)put [Authorize] attribute before Controller
This will redirect the user to login page

Mahesh Odedra
- 59
- 1
- 7