Tag Archives: Which one is faster @Html.Partial and @Html.RenderPartial

@Html.Partial vs @Html.RenderPartial in Asp.Net MVC

@Html.Partial

  • @Html.Partial returns string.
  • Syntax : @Html.Partial(“Partial View Name”).
  • Pass model with Partial method Syntax : @Html.Partial(“Partial View Name”, Model).
  • It is slower as compared to @Html.RenderPartial.
  • It’s result can be manipulated before rendering to the output stream.
  • Manipulation : @{ var data= Html.Partial(“Partial View Name”); } @data I am Software Developer.
  • Use when data length is small or need to manipulate result before rendering to the output stream.

@Html.RenderPartial

  • @Html.RenderPartial returns void.
  • Syntax : @{ Html.RenderPartial(“Partial View Name”); }
  • Pass model with RenderPartial method Syntax : @{ Html.RenderPartial(“Partial View Name”, Model); }
  • It is faster as compared to @Html.Partial because this result is written directly to the output stream.
  • It’s result can not be manipulated.
  • Use when data length is large or no need to manipulate result before rendering to the output stream.