如何清除在asp.net服务器缓存? [英] How do I clear the server cache in asp.net?

查看:257
本文介绍了如何清除在asp.net服务器缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何清除asp.net服务器缓存?我们发现,有两种缓存。还有就是浏览器缓存和服务器缓存。我已经做了一些搜索,但我还没有找到一个明确的,一步一步的指导使用asp.net(或没有)清除服务器缓存。

How do I clear the server cache in asp.net? I have found out that there are two kinds of cache. There is the browser cache and the server cache. I have done some searching but I have yet to find a clear, step-by-step guide for clearing the server cache using asp.net (or not).

(更新)我刚刚了解到,code-背后因为这是在VB - Visual Basic中(点净额)。

(update) I just learned that the code-behind for this is in VB - Visual Basic (dot net).

推荐答案

您可以遍历所有缓存项并删除它们一个接一个:

You could loop through all the cache items and delete them one by one:

foreach (System.Collections.DictionaryEntry entry in HttpContext.Current.Cache){
    HttpContext.Current.Cache.Remove(string(entry.Key));
}

语法校正ASP.NET 4.5 C#

Syntax Correction for ASP.NET 4.5 C#

foreach (System.Collections.DictionaryEntry entry in HttpContext.Current.Cache){
    HttpContext.Current.Cache.Remove((string)entry.Key);
}

这篇关于如何清除在asp.net服务器缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆