猿问

清除缓存有时会报这个错,不知道如何处理它

    try
            {
            IDictionaryEnumerator DicCache = HttpRuntime.Cache.GetEnumerator();            int count = HttpRuntime.Cache.Count;            for (int i = 0; i < count; i++)
            {
                DicCache.MoveNext();
                HttpRuntime.Cache.Remove(DicCache.Entry.Key.ToString());
            }
            }            catch (Exception)
            {                throw;
            }


一只萌萌小番薯
浏览 420回答 1
1回答

炎炎设计

试试下面的代码try{ &nbsp;&nbsp;&nbsp;&nbsp;IDictionaryEnumerator&nbsp;DicCache&nbsp;=&nbsp;HttpRuntime.Cache.GetEnumerator();&nbsp;&nbsp;&nbsp;&nbsp;while(DicCache.MoveNext()) &nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HttpRuntime.Cache.Remove(DicCache.Entry.Key.ToString()); &nbsp;&nbsp;&nbsp;&nbsp;} }catch&nbsp;(Exception) {&nbsp;&nbsp;&nbsp;&nbsp;throw; }
随时随地看视频慕课网APP
我要回答