How to Clear OutputCache for Website without Restarting App

白昼怎懂夜的黑 提交于 2020-01-10 18:53:10

问题


Is there a way clear or reset the outputcache for an entire website without a restart?

I'm just starting to use outputcache on a site and when I make a mistake in setting it up I need a page I can browse to that will reset it.


回答1:


This should do the trick:

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

 Dim path As String
 path="/AbosoluteVirtualPath/OutputCached.aspx"
 HttpResponse.RemoveOutputCacheItem(path)

End Sub



回答2:


Add the following code to controller or to page code:

HttpContext.Cache.Insert("Page", 1);
Response.AddCacheItemDependency("Page");

To clear output cachne use the following command in controller:

    HttpContext.Cache.Remove("Page");


来源:https://stackoverflow.com/questions/37101/how-to-clear-outputcache-for-website-without-restarting-app

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