System.Web.UI.Page.Cache 页面 缓存 清除

这个也是网上查询到方法,不错记录一下!

/// <summary>
/// 清空所有的Cache
/// </summary>
public static void ClearCache()
{
List<string> cacheKeys = new List<string>();
IDictionaryEnumerator cacheEnum = HttpContext.Current.Cache.GetEnumerator();
while (cacheEnum.MoveNext())
{
cacheKeys.Add(cacheEnum.Key.ToString());
}
foreach (string cacheKey in cacheKeys)
{
HttpContext.Current.Cache.Remove(cacheKey);
}
}

 

posted @ 2017-06-19 11:47  三瑞  阅读(240)  评论(0编辑  收藏  举报