1
永久缓存动作结果的最佳方式是什么?直到应用程序重新启动。缓存应用程序生命周期的动作结果
// Cache this result forever, it will reset on app restart
[OutputCache(Duration=999999)]
[ChildActionOnly]
public ActionResult Footer()
{
if (HttpContext.Application != null && HttpContext.Application.AllKeys.Contains("Version"))
return Content(HttpContext.Application["Version"].ToString());
return null;
}
有没有更好的方法来做到这一点?
我不知道更好的方法。您可以创建自己的属性`ForeverOutputCache`,它将在构造函数中设置`Duration = Int32.MaxValue`,但这几乎是相同的方法。 – 2011-12-16 09:45:18