Click here to Skip to main content
15,889,403 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

this is my code

C#
Session.Abandon();
Session.Clear();
Response.Expires = 1;
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);// Now(-1);
Response.AddHeader("pragma",
"no-cache");
Response.AddHeader("cache-control",
"private");
Response.CacheControl = "no-cache";
Request.Cookies.Clear();
Response.Cookies.Clear();
FormsAuthentication.SignOut();
Session["User"]=null;
if (Session["User"] == null)
{
    return View();
}

its working on crome.But in firefox after logout also redirecting to previous pages,
means window history is not deleting, even if i used window.history.forward() also same issue.

how can i resolve it?
Posted
v2

Take a look at the Excellent Tip by Sandeep Mewara- Browser back button issue after logout[^]
 
Share this answer
 
You can put following code on get action ,

C#
Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
               Response.Cache.SetValidUntilExpires(false);
               Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
               Response.Cache.SetCacheability(HttpCacheability.NoCache);
               Response.Cache.SetNoStore();
               ViewBag.Message = null;
               if (Session == null)
               {

                   return RedirectToAction("Index", "Login");

               }
               else
               {
                   if (Session.Count == 0)
                   {
                       return RedirectToAction("Index", "Login");
                   }
               }
           }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900