AddCacheItemDependency 用于使用以下代码清除 Mono Apache MVC2 应用程序中的 OutputCache。 这在 Clearing Page Cache in ASP.NET 中有描述。
在 Mono 中,OutputCache 不会被清除。 查看 GitHub 中的源代码表明 AddCacheItemDependency 未在 Mono 中实现。 如何解决此问题以便清除 OutputCache?
安德鲁斯。
[OutputCache(Duration = 3600, VaryByParam = "none")]
public ActionResult Index()
{
HttpContext.Current.Response.AddCacheItemDependency("Pages");
return View();
}
public ActionResult Refresh()
{
HttpRuntime.Cache.Insert( "Pages", DateTime.Now);
}
在 Global.asax.cs 中:
protected void Application_Start()
{
HttpRuntime.Cache.Insert( "Pages", DateTime.Now);
}
最佳答案
您是否尝试手动删除输出缓存?
喜欢:
var urls = new List<string> {
Url.Action("Index", "ControllerName", new { area = "AreaName" }))
};
urls.ForEach(HttpResponse.RemoveOutputCacheItem);
关于c# - 如何清除 Mono MVC2 应用程序中的 OutputCache,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12913856/