13

I am trying to understand the difference between a RenderPartial and RenderAction. I guess that RenderPartial is like a UserControl and RenderAction is like a server-side include. Can someone put this in perspective please and if possible give me a couple scenarios of where each would be used?

Skadoosh
  • 2,575
  • 8
  • 40
  • 53
  • 1
    The difference between RenderPartial and RenderAction is the difference between a Partial and an Action. – bzlm Oct 19 '10 at 13:14

3 Answers3

21

Have you seen this blog post?

Summary:

  • RenderPartial: You are responsible for providing a model, performing logic etc.
  • RenderAction: You are responsible for invoking an action, that controller is responsible for providing a model, performing logic etc.

Furthermore, RenderPartial will render a particular View, RenderAction can render any View it want, it's up to the controller. For example: an action that displays a View with login information might return one view when you are a guest (not authenticated), one View when you are authenticated as a regular user, and one View when you are an admin. You, as the caller of RenderAction don't have to care at all, you just call your action

Onkelborg
  • 3,927
  • 1
  • 19
  • 22
  • 1
    For broken link: https://web.archive.org/web/20101125043437/http://blogs.intesoft.net/post/2009/02/renderaction-versus-renderpartial-aspnet-mvc.aspx – jaybro Jun 25 '15 at 15:49
3

RenderPartial specifies a partial view and passes a model to it.

RenderAction specifies a controller and an action, any model data will be gathered by the controller.

This is quite a good explanation

Paul Creasey
  • 28,321
  • 10
  • 54
  • 90
2

Below is a good link that helps describe the difference and when to use them.

http://blogs.intesoft.net/post/2009/02/renderaction-versus-renderpartial-aspnet-mvc.aspx

John Hartsock
  • 85,422
  • 23
  • 131
  • 146