2

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?

1 Answer 1

6

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.