ASP.NET MVC 2.0 - Difference between RenderPartial and RenderAction

前端 未结 3 432
旧时难觅i
旧时难觅i 2021-01-11 13:06

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 i

3条回答
  •  梦谈多话
    2021-01-11 13:28

    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

提交回复
热议问题