Manually clear ASP.NET server cache for a single application/web site?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 20:38:59

问题


How can I manually clear ASP.NET server cache (IIS 7) on a given application/website, like what can be done in IE to clear browser cache for a given domain?


回答1:


Use the following to remove all objects from the cache

IDictionaryEnumerator enumerator = HttpContext.Current.Cache.GetEnumerator();

while (enumerator.MoveNext())
{

    HttpContext.Current.Cache.Remove((string)enumerator.Key);

}

Also, it is a bit of a sledgehammer option but you can restart the entire application as follows:

System.Web.HttpRuntime.UnloadAppDomain();



回答2:


I had the same problem, and recycling the application pool helped me. All my caches immediately reloaded as I wanted.



来源:https://stackoverflow.com/questions/5275349/manually-clear-asp-net-server-cache-for-a-single-application-web-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!