如何在不重新启动应用程序的情况下清除网站的OutputCache
-
09-06-2019 - |
题
有没有办法清除或重置整个网站的输出缓存而无需重新启动?
我刚刚开始在网站上使用输出缓存,当我在设置中犯了错误时,我需要一个可以浏览的页面来重置它。
解决方案
这应该可以解决问题:
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
其他提示
将以下代码添加到控制器或页面代码中:
HttpContext.Cache.Insert("Page", 1);
Response.AddCacheItemDependency("Page");
要清除输出缓存,请在控制器中使用以下命令:
HttpContext.Cache.Remove("Page");
不隶属于 StackOverflow