@Html.RenderAction/Partial VS @Html.Action/Partial & @Html.Partial VS @Html.Action

Refer to http://www.em64t.net/2010/12/razor-html-renderpartial-vs-html-partial-html-renderaction-vs-html-action-what-one-should-use/

Html.RenderAction VS Html.Action

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.

On the other side, I do not entirely through away @Html.Partial and @Html.Action. These methods are good for some cases when you need to put sub-template content into a variable or do something with it (which was a pain in older MVC versions). And they may be life-saving in certain scenarios like caching.

 

Html.RenderAction VS Html.RenderPartial
There is a big difference between RenderAction and RenderPartial. RenderPartial will render a View on the same controller (or a shared one), while RenderAction will actually perform an entire cycle of MVC, that is: it will instantiate the controller (any controller you mention, not just the current one), it will execute the action, and it will then return and render the result.

posted @ 2012-09-28 10:35  webglcn  阅读(257)  评论(0编辑  收藏  举报