【发布时间】:2025-12-16 16:35:01
【问题描述】:
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);
}
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-3 mono outputcache