I would like to clear all cache in my Application when user Logout.
\The website has 2 type of members and when member1 Visit ../department1.aspx and logout, i can still see the page by typing ../departement1.aspx in the Browser
I try to debug it but it seems like by typing the url in browser, it display the page. But when hit F5 it then bring me to the Login.aspx
I think this is a Cache issue and i use this at logout.aspx
protected
override void OnLoad( EventArgs e )
{
base.OnLoad( e );
var authCookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
if ( authCookie != null )
{
authCookie.Expires = DateTime.Now.AddDays( -1 );
}
ClearApplicationCache();
Session.Abandon();
FormsAuthentication.SignOut();
FormsAuthentication.RedirectToLoginPage();
}
public void ClearApplicationCache()
{
List<string> keys = new List<string>();
// retrieve application Cache enumerator
IDictionaryEnumerator enumerator = Cache.GetEnumerator();
// copy all keys that currently exist in Cache
while (enumerator.MoveNext())
{
keys.Add(enumerator.Key.ToString());
}
// delete every key from cache
for (int i = 0; i < keys.Count; i++)
{
Cache.Remove(keys[i]);
}
}
But Still Not working. Any Help?