Html.Partial vs Html.RenderPartial & Html.Action vs Html.RenderAction in mvc

Total Post:128

Points:898
C#  Mvc 
 2040  View(s)
Ratings:
Rate this:

In ASP.NET MVC, what is the difference between:

  • Html.Partial and Html.RenderPartial
  • Html.Action and Html.RenderAction
  1. Post:154

    Points:1086
    Re: Html.Partial vs Html.RenderPartial & Html.Action vs Html.RenderAction in mvc

    Html.Partial returns a String, Html.RenderPartial calls Write internally, and returns void.

    The basic usage is:

    // Razor syntax
    @Html.Partial("ViewName")
    @{ Html.RenderPartial("ViewName");  }
    // WebView syntax
    <%: Html.Partial("ViewName") %>
    <% Html.RenderPartial("ViewName"); %>

    In the snippet above, both calls will yield the same result.

    While one can store the output of Html.Partial in a variable or return it from a method, one cannot do this with Html.RenderPartial. The result will be written to the Response stream during execution/evaluation.

    This also applies to Html.Action and Html.RenderAction.

      Modified On Apr-06-2018 06:49:49 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!