页首Html代码

Asp.net中显示所有缓存 清除所有缓存

 1   //清除所有缓存
2 protected void RemoveAllCache()
3 {
4 System.Web.Caching.Cache _cache = HttpRuntime.Cache;
5 IDictionaryEnumerator CacheEnum = _cache.GetEnumerator();
6 ArrayList al = new ArrayList();
7 while (CacheEnum.MoveNext())
8 {
9 al.Add(CacheEnum.Key);
10 }
11 foreach (string key in al)
12 {
13 _cache.Remove(key);
14 }
15 show();
16 }
17 //显示所有缓存
18 void show()
19 {
20 string str = "";
21 IDictionaryEnumerator CacheEnum = HttpRuntime.Cache.GetEnumerator();
22
23 while (CacheEnum.MoveNext())
24 {
25 str += "缓存名<b>[" + CacheEnum.Key+"]</b><br />" ;
26 }
27 this.Label1.Text = "当前网站总缓存数:" + HttpRuntime.Cache.Count + "<br />"+str;
28 }
posted @ 2011-09-24 00:28  Hauk.Wong  阅读(362)  评论(0)    收藏  举报
页脚Html代码