Tuesday 12 February 2013

How to clear Cache on logout in c#



Call this method on page load for clearing cache

 public void ClearApplicationCache()
    {
        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]);
        }
    }

No comments:

Post a Comment