Clear the .NET Application Cache

The code below clears all the cached data in your web application for .NET 
This is also can be used in ASP.NET MVC's OutputCachedPage.

public void ClearApplicationCache() { List keys = new List(); // 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]); } }
  • 59 Kasutajad peavad seda kasulikuks
Kas see vastus oli kasulik?

Powered by WHMCompleteSolution