c# - 如何清除 Mono MVC2 应用程序中的 OutputCache

标签 c# asp.net-mvc asp.net-mvc-3 mono outputcache

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/

相关文章:

c# - .NET 的 Double.ToString 方法中的两次错误

c# - 确保 Controller 有一个无参数的公共(public)构造函数

asp.net-mvc - ASP.net MVC - 我可以告诉 Html.Partial 在哪里可以找到 View 吗?

asp.net-mvc - 使用 HTML.BeginForm 时,ReturnUrl 如何存储在 MVC4 Razor 页面中?

c# - 找不到程序集“mscorlib,版本 = 2.0.5.0

c# - 属性内容被设置多次

c# - 为什么我的流不可读?

c# - 放置多个显示错误 :There is already an open DataReader associated with this Command which must be closed first 的 sql 命令时

asp.net-mvc - 我的 Azure 上的 MVC 应用程序出现 500 错误

c# - Razor:在循环中添加变量而不显示它