– ASP.NET MVC ViewResult vs PartialViewResult

What is the difference between the controller result named ViewResult and PartialViewResult? More importantly, when is the PartialViewResult used?

Best Answer

PartialViewResult is used to render a partialview (fx. just a user control). This is pretty nifty for AJAX stuff, i.e.

<script type="text/javascript">
        function (data) { $("#target").html(data) }

and action

public ActionResult MyAction() 
    return PartialView("SomeView");

where SomeView is a MVC User Control, e.g.:

   <%= DateTime.Now.ToString() %>