Patrick Desjardins Blog
Patrick Desjardins picture from a conference

RenderPartial vs RenderAction

Posted on: 2012-03-30

ASP.NET MVC website describe pretty well the difference between the two. RenderPartial is used to display a reusable part of within the same controller and RenderAction render an action from any controller. They both render the Html and doesn't provide a String for output.

Here is a picture that illustrate the difference between RenderPartial and RenderAction in Asp Mvc .Net.

If you need to have a String, which can be the case if you need to return by Ajax the content in Html you should use Html.Partial or Html.Action. They both create the view but instead of rendering it directly into the Http Response will produce an Html string which could be returned to be loaded into a div with Javascript or JQuery.

$('#result').load('http://localhost/myApp/User/Profile/1'); 

This is a small example where the action Profile of the controller User could return directly a String. To be able to generate this output server side, it would require that the Profile action return ContentResult type that will be generated by Html.Partial or Html.Action.