是否可以从一个操作中清除另一个操作的缓存?
假设我的索引操作列出了我的所有小部件。有很多小部件,但新的小部件并不经常创建。因此,我想无限期地缓存我的索引操作,但在成功创建后强制它呈现。
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/