【发布时间】:2008-08-31 21:03:14
【问题描述】:
有没有办法在不重启的情况下清除或重置整个网站的输出缓存?
我刚开始在网站上使用 outputcache,当我设置错误时,我需要一个可以浏览的页面来重置它。
【问题讨论】:
标签: asp.net outputcache
有没有办法在不重启的情况下清除或重置整个网站的输出缓存?
我刚开始在网站上使用 outputcache,当我设置错误时,我需要一个可以浏览的页面来重置它。
【问题讨论】:
标签: asp.net outputcache
这应该可以解决问题:
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");
【讨论】: