MVC 3 Response.Flush不起作用

时间:2011-08-10 08:30:13

标签: asp.net-mvc razor response

我有下一个观点代码:

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

在这种情况下,我希望首先呈现页面的标题,然后使用页脚呈现主体,但响应会发送整个页面。

1 个答案:

答案 0 :(得分:5)

我找到了答案:

public ActionResult Index(DateTime from, DateTime to)
{
  PartialView("PartialViews/_ReportHeader").ExecuteResult(ControllerContext);
  Response.Flush();
  ViewBag.Report = new InHouseFarmInFarmOutReportGenerator().GenerateReport(from, to);
  return View();
}