您的位置:首页 > Web前端 > HTML

Razor: @Html.Partial() vs @RenderPage()

2014-04-04 10:19 316 查看
Html.Partial("MyView")
Renders the "MyView" view to an
MvcHtmlString
. It follows the standard rules for view lookup (i.e. check current directory, then check the
Shared
directory).
Html.RenderPartial("MyView")
Does the same as
Html.Partial()
, except that it writes its output directly to the response stream. This is more efficient, because the view content is not buffered in memory. However, because the method does not return any output,
@Html.RenderPartial("MyView")
won't work. You have to wrap the call in a code block instead:
@{Html.RenderPartial("MyView");}
.
RenderPage("MyView.cshtml")
Renders the specified view (identified by path and file name rather than by view name) directly to the response stream, like
Html.RenderPartial()
. You can supply any model you like to the view by including it as a second parameter
RenderPage("MyView.cshtml",MyModel)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐