有没有一种方法或某种方法可以强制HttpContext的Cache集合中的所有条目到期?

最佳答案

尝试这样的事情:

var enumerator = HttpRuntime.Cache.GetEnumerator();
Dictionary<string, object> cacheItems = new Dictionary<string, object>();

while (enumerator.MoveNext())
    cacheItems.Add(enumerator.Key.ToString(), enumerator.Value);

foreach (string key in cacheItems.Keys)
    HttpRuntime.Cache.Remove(key);

关于c# - 强制所有ASP.NET缓存过期,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2884360/

10-09 08:49