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)