Reputation: 165
Is it possible to clear asp.net cache? Is there different ways to do that?
For example is it possible to do that on IIS(7.5) side? Is it possible to do by selecting the application i want to clear cache in on IIS manager console? IIS i have one option to do that - application restart which is basically doing more than that but i want just clear the cache, may be there is any IIS extensions which doing that?
Should i write the code to do that for example from admin part of web site?
Upvotes: 2
Views: 4297
Reputation: 19047
Here is a code that cleans up the Application Cache from Application side. I dont know of a way cleaning it from IIS.
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]);
}
}
Now just make a page for that or a button to call that from Admin Panel :)
Good Luck.
Taken From: aspdotnetfaq.com
Upvotes: 6