1

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.

Nigar
  • 59
  • 3
  • 10

3 Answers3

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");
}
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