MVC 3中的Response.Flush无法工作

3

我有下面这段视图代码:

@{ Layout = null; }
@Html.Raw(ViewBag.ReportHeader as string)
@{
    Response.Buffer = true;
    Response.Flush();
}
@Html.Raw(ViewBag.ReportBodyAndFoot as string)

在这种情况下,我期望页面的标题先被渲染,然后是正文和页脚,但响应发送了整个页面。
1个回答

5
我找到了答案:
public ActionResult Index(DateTime from, DateTime to)
{
  PartialView("PartialViews/_ReportHeader").ExecuteResult(ControllerContext);
  Response.Flush();
  ViewBag.Report = new InHouseFarmInFarmOutReportGenerator().GenerateReport(from, to);
  return View();
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接