Est-il possible d'effacer le cache d'une action d'une autre action?ASP.NET MVC: Effacer le cache d'une action d'une autre action
Supposons que mon action Index répertorie tous mes widgets. Il y a beaucoup de Widgets mais de nouveaux ne sont pas créés très souvent. Je veux donc mettre en cache indéfiniment mon action d'index, mais la forcer à afficher après une création réussie.
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);
}
}
duplication possible de [Comment "invalider" des portions de cache de sortie ASP.NET MVC?] (Http://stackoverflow.com/questions/1288463/how-to-invalidate-portions-of-asp-net-mvc -output-cache) – bzlm