Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to clear browser history when login page load. i want to clear history and cache when my application is initialize.how to do it.i use some codes but not works

What I have tried:

<META Http-Equiv="Cache-Control" Content="no-cache"/>
<META Http-Equiv="Pragma" Content="no-cache"/>
<META Http-Equiv="Expires" Content="0"/>


protected void LogOut()
{
     Session.Abandon();
     string loggedOutPageUrl = "Logout.aspx";
     Response.Write("<script language="'javascript'">");
     Response.Write("function ClearHistory()");
     Response.Write("{");
     Response.Write(" var backlen=history.length;");
     Response.Write(" history.go(-backlen);");
     Response.Write(" window.location.href='" + loggedOutPageUrl + "'; ");
     Response.Write("}");
     Response.Write("</script>");
}

public void ClearCacheItems()
{
   List<string> keys = new List<string>();
   IDictionaryEnumerator enumerator = Cache.GetEnumerator();
 
   while (enumerator.MoveNext())
     keys.Add(enumerator.Key.ToString());
 
   for (int i = 0; i < keys.Count; i++)
      Cache.Remove(keys[i]);
} 
Posted
Updated 31-May-17 22:10pm

1 solution

You can't clear the browser history.
 
Share this answer
 
Comments
Raja Ganapathy 1-Jun-17 4:56am    
this is for any security reasons?
F-ES Sitecore 1-Jun-17 5:05am    
General usability really. Browser history is an aspect of the browser and it is for the user to control, not your web page. A web page that deleted your browser history would be like a mechanic that takes the stereo from your car.

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