Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html.Partial vs Html.RenderPartial & Html.Action vs Html.RenderAction. can any one please describe the difference

In ASP.NET MVC, what is the difference between:

Html.Partial and Html.RenderPartial
Html.Action and Html.RenderAction
like image 815
Nikhil Saswade Avatar asked May 15 '15 10:05

Nikhil Saswade


1 Answers

Html.Action invokes the controller's action, which means it instantiates the controller entity, calls an action method, which builds a model an returns a view result.

Html.Partial uses already created model (or can be called without model at all) to render a specified view.

When to use one over the other? If you already have a model and just want to have a reusable view, opt to Html.Partial. If you see that some piece deserves its own model and action, maybe it makes sense to use Html.Action.

This question is discussed in much greater details in this article, and what you see above is basically an excerpt from it.

like image 110
Andrei Avatar answered Sep 21 '22 01:09

Andrei