如何在不重新启动应用程序的情况下清除网站的OutputCache

时间:2008-08-31 21:03:15

标签: asp.net outputcache

有没有办法清除或重置整个网站的outputcache而不重启?

我刚开始在网站上使用outputcache,当我在设置时出错时,我需要一个可以浏览的页面来重置它。

2 个答案:

答案 0 :(得分:9)

这应该可以解决问题:

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

答案 1 :(得分:0)

将以下代码添加到控制器或页面代码中:

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

要清除输出cachne,请在控制器中使用以下命令:

    HttpContext.Cache.Remove("Page");