Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can anyone please provide me the code to clear image caching
Posted

1 solution

ASP.NET comes with very powerful caching mechanism that can be used to easily improve responsiveness and efficiency of your web applications.

Here is the code snippet that clears all cached data in your web application:

C#
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]);
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900