【发布时间】:2011-02-26 12:00:16
【问题描述】:
我正在尝试利用 .Net MVC 3 中的甜甜圈缓存功能。对于我的主页,在我的家庭控制器中,我有:
public ActionResult Index()
{
return View();
}
[ChildActionOnly]
[OutputCache(Duration=3600)]
public ActionResult IndexMain()
{
return PartialView(ViewModelRepository.GetIndexViewModel());
}
我的看法,我有:
<% Html.RenderAction("IndexMain");%>
这一切都很好。但是,当数据发生变化时,我运行:
var urlToRemove = Url.Action("IndexMain", "Home");
Response.RemoveOutputCacheItem(urlToRemove);
RemoveOutputCacheItem 执行没有错误,但 ChildAction 缓存没有失效。有没有办法以编程方式从 ChildAction 中删除缓存项?
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-3 outputcache