Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Saied 349 posts 674 karma points
    Jul 07, 2015 @ 15:18
    Saied
    0

    @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?

  • Ste 14 posts 35 karma points
    Jul 08, 2015 @ 08:58
    Ste
    1

    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 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

    For 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

Please Sign in or register to post replies

Write your reply to:

Draft