Asp.net mvc 4 MVC 4儿童行动';s outputcache属性不使用VaryByParam值

Asp.net mvc 4 MVC 4儿童行动';s outputcache属性不使用VaryByParam值,asp.net-mvc-4,outputcache,child-actions,varybyparam,Asp.net Mvc 4,Outputcache,Child Actions,Varybyparam,是否无法根据查询值缓存子操作的输出 public class HomeController : Controller { public ActionResult About() { ViewBag.Message = DateTime.Now.ToLongTimeString(); return View(); } [OutputCache(Duration = 20, VaryByParam = "id")] publ

是否无法根据查询值缓存子操作的输出

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>
公共类HomeController:控制器
{
关于()的公共行动结果
{
ViewBag.Message=DateTime.Now.ToLongTimeString();
返回视图();
}
[OutputCache(持续时间=20,VaryByParam=“id”)]
公共行动结果第二部分
{
ViewBag.Second=DateTime.Now.Second;
返回视图();
}
}
关于.cshtml
@ViewBag.Title。
@查看包。留言
@Html.Action(“PartialViewTestAbout”)
.
.
.
PartialViewTestAbout.cshtml:
----------

这是一个局部的看法。
@查看包。留言
@第二个


没有varybyparam它工作得很好。但是我需要根据参数刷新partialViewBoutSet。如果我打开OutPutCache,那么关于ActionREsult和VaryByParam的操作正在工作。但是,对于PartailViewTestAbout的子操作,在本例中它不起作用,我更改了查询,但没有等待缓存持续时间太长来刷新页面…

答案是,缺少的id参数没有传递到PartialViewTestAbout

[OutputCache(Duration = 20, VaryByParam = "id")]

public ActionResult PartialViewTestAbout(int id)
这很有效

感谢Cem LEGOZ:)