Partial view call in asp.net MVC3

What is the difference between Html.Partial and Html.action in the context of using partial view in asp.net MVC3?

+6
source share
3 answers

Html.Action will call the Action controller, so it will go through the entire MVC pipeline again (inside the server) to find the controller that will return the ViewResult (although you could theoretically also return JsonResult or something else).

Html.Partial will return PartialPage (as in the CSHTML file) and the entire pipeline will not pass. He will just search using the viewer.

Some benefits to Action are authentication, caching, and other things that happen in the MVC pipeline, while Partial is faster (although there may be more responsibility on a partial page if you need to pass a ViewModel, etc.)

This is a good post (a bit old) about the pros and cons of RenderAction vs RenderPartial

+10
source

Html.Partial includes the view directly in the place where you called the helper. It looks like a file.

Html.Action first calls the controller action, which can display the view, and this is the result of this action. And since the action of the controller is called, the controller must be created, so the entire MVC pipeline runs as a child request.

You can see the next blog post .

+4
source

Source: https://habr.com/ru/post/885437/


All Articles