繁体   English   中英

如何在Mono MVC2应用程序中清除OutputCache

[英]How to clear OutputCache in Mono MVC2 application

AddCacheItemDependency用于使用下面的代码在Mono Apache MVC2应用程序中清除OutputCache。 在ASP.NET清除页面缓存中对此进行了描述

在Mono中,不清除OutputCache。 查看GitHub中的源代码可知,在Mono中未实现AddCacheItemDependency。 如何解决此问题,以便可以清除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);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM