asp.net-mvc - ASP.NET MVC : Clear an action's cache from another action

标签 asp.net-mvc caching

是否可以从一个操作中清除另一个操作的缓存?

假设我的索引操作列出了我的所有小部件。有很多小部件,但新的小部件并不经常创建。因此,我想无限期地缓存我的索引操作,但在成功创建后强制它呈现。

public class WidgetController : Controller
{
    [OutputCache(Duration = int.MaxValue, VaryByParam = "none")]
    public ActionResult Index()
    {
        return View(Widget.AllWidgets);
    }

    public ActionResult Create()
    {
        return View();
    }

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Create(string name)
    {
        Widget widget = new Widget(name);

        // Can I clear Index's cache at this point?
        // ClearCache("Index");

        return View(widget);
    }
}

最佳答案

HttpResponse.RemoveOutputCacheItem?

关于asp.net-mvc - ASP.NET MVC : Clear an action's cache from another action,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1637815/

相关文章:

java - 1GB 内存上的 memcached tomcat mysql

使用 Memcached 进行 Spring-Hibernate 缓存

php - 缓存 php 生成的 javascript 页面

c# - 如何使用不同的注入(inject)重新实例化 MVC3 Controller

asp.net-mvc - 忽略 asp.net mvc razor View 中的 viewstart?

asp.net-mvc - 不正确的 http header 字段值编码

c# - Html DropDownListFor asp.net C#

jquery - MVC jquery 文件上传传递参数

caching - 当http post请求并且没有缓存时处理浏览器后退按钮

javascript - 我可以告诉 Web 浏览器不要缓存特定文件吗?