zoukankan      html  css  js  c++  java
  • 如何从Asp.net应用程序中移除所有Cache对象

       Cache是Asp.net中非常强大的功能,我们使用它来提高应用程序的性能。有时我们需要在某个任务结束后移除所有Cache对象,如何做呢?有以下两段代码可以使用:

       1:              IDictionaryEnumerator cacheEnumerator = HttpContext.Current.Cache.GetEnumerator();
       2:   
       3:              while (cacheEnumerator.MoveNext())
       4:              {
       5:                  HttpContext.Current.Cache.Remove(cacheEnumerator.Key.ToString());
       6:              }

    OR:

       1:              foreach (DictionaryEntry dEntry in HttpContext.Current.Cache)
       2:              {
       3:                  HttpContext.Current.Cache.Remove(dEntry.Key.ToString());
       4:              }

    很简单,希望这篇POST对您有帮助。

    Author:  Petter Liu  http://wintersun.cnblogs.com

  • 相关阅读:
    【WPF】【基础】布局系统
    【设计】【托管扩展性框架】 MEF vs 2010 samples
    【wpf】【控件】内容控件
    【Wpf】【debug】Exception has been thrown by the target of an invocation.
    【设计模式】概述
    期待与悲催中的2012
    金额转为大写人民币
    使用vs2005的GridView控件,菜鸟问题。
    Microsoft Visual Studio 2005中使用水晶报表
    将金额小写转化成汉字大写(javascript)
  • 原文地址:https://www.cnblogs.com/wintersun/p/1671920.html
Copyright © 2011-2022 走看看