Difference between Html.RenderAction and Html.Action

28,418

Solution 1

Html.Action() – Outputs string

Html.RenderAction() – Renders directly to response stream

If the action returns a large amount of HTML, then rendering directly to the response stream provides better performance than outputting a string.

Solution 2

The difference between the two is that Html.RenderAction will render the result directly to the Response (which is more efficient if the action returns a large amount of HTML) whereas Html.Action returns a string with the result.

check out this link for a detailed explanation

Share:
28,418
Sasha
Author by

Sasha

Updated on March 20, 2020

Comments

  • Sasha
    Sasha about 4 years

    Does anybody know what's the difference between Html.RenderAction and Html.Action?

  • Admin
    Admin over 13 years
    So when would you use Html.Action if RenderAction gives better performance?
  • David Kassa
    David Kassa about 11 years
    @user76071 from another question with Action you can put the result in a variable or return it from a function.
  • Jordan
    Jordan almost 8 years
    Better performance? Barely. This is a bad case of premature optimization. Unless you are outputting a huge wiki article, the differences are negligible. Personally, I find Html.Action more readable and only use Html.RenderAction if I am in a code block.
  • user1161391
    user1161391 over 5 years
    Below article In answer below, states RenderAction is better when rendering a lot of HTML, (like a partial View.) That's why I like it better.