public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (filterContext.Controller.ViewData["currentuser"] == null)
{
filterContext.Result = new HomeController().IndexCache();
}
base.OnActionExecuting(filterContext);
}
[OutputCache(Duration=3600)]
public ActionResult IndexCache()
{
return view()
}
这是行不通的。如果用户未登录,我想返回缓存。这不是最终代码。
在为它们提供缓存的 Index() 之前,我需要检查 action = "index" 和 controller = "home"。
当我创建控制器时,新实例没有被缓存。有人能告诉我如何在这段代码中返回缓存索引吗?