是否无法根据查询值缓存子操作的输出?
public class HomeController : Controller
{
public ActionResult About()
{
ViewBag.Message = DateTime.Now.ToLongTimeString();
return View();
}
[OutputCache(Duration = 20, VaryByParam = "id")]
public ActionResult PartialViewTestAbout()
{
ViewBag.Second = DateTime.Now.Second;
return View();
}
}
About.cshtml
<hgroup class="title">
<h1>@ViewBag.Title.</h1>
<h2>@ViewBag.Message</h2>
</hgroup>
@Html.Action("PartialViewTestAbout")
.
.
.
PartialViewTestAbout.cshtml:
----------
<p>
This is a partial view About.
<h1 style="color:red;">@ViewBag.Message</h1>
@ViewBag.Second
</p>
没有varybyparam,它工作得很好。但是我需要根据参数刷新 PartialViewAboutTest。如果我将 OutPutCache 放在 About ActionREsult 上,并且 VaryByParam 正在工作。但是对于本示例中的 ParttailViewTestAbout 子操作,它不起作用,我更改了查询,但没有等待缓存持续时间很长来刷新页面......