@Html.Action vs @Html.Partial vs @Html.RenderPartial with SurfaceControllers
I just finished watching a video on SurfaceControllers on umbraco.tv and in the video, @Html.Action() was used in the template, but in other videos online, I have seen some use @Html.Partial() and others use @Html.RenderPartial().
As I understand it, you use Action when calling a controller action because it lets you specify the Controller as well as the Action to use from the controller.
Partial and RenderPartial both let you just specify a View name and MVC magically find the right view and renders it. The difference between these two is:
Partial returns an HtmlString which you have to output, for example using @() syntax.
RenderPartial writes the result directly to the output string and has better performance
@Html.Action vs @Html.Partial vs @Html.RenderPartial with SurfaceControllers
I just finished watching a video on SurfaceControllers on umbraco.tv and in the video,
@Html.Action()
was used in the template, but in other videos online, I have seen some use@Html.Partial()
and others use@Html.RenderPartial()
.What is the preferred way?
When would you use one way over the other?
Hi Saied,
As I understand it, you use
Action
when calling a controller action because it lets you specify the Controller as well as the Action to use from the controller.Partial
andRenderPartial
both let you just specify a View name and MVC magically find the right view and renders it. The difference between these two is:Partial
returns an HtmlString which you have to output, for example using@()
syntax.RenderPartial
writes the result directly to the output string and has better performanceFor more info, check out this on Stack Overflow: What is the difference between Html.Partial and Html.RenderPartial
And this article RenderPartial vs RenderAction vs Partial vs Action in MVC Razor
is working on a reply...