Raja

Raja

  • 552
  • 2k
  • 345.6k

How to clear browser history when login time?

Jun 1 2017 3:04 AM
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]);
}


 

Answers (2)