RenderAction RenderPartial

Very old one, but it jumped into my list of unanswered questions 🙂

There is a big difference between RenderAction and RenderPartial. RenderPartial will render a View on the same controller (or a shared one), while RenderAction will actually perform an entire cycle of MVC, that is: it will instantiate the controller (any controller you mention, not just the current one), it will execute the action, and it will then return and render the result.

The RenderPartial is more similar to an inclusion, it will even share the same model if you don’t specify a different one.

The RenderAction is much more complex (and there may be undesired side effects, that’s why they did not make this function available since version 1 — initially it was available as an experimental feature).

So in your case, if you have widgets, it’s OK to use both. It depends on the complexity of the widget. If you have one that has to get data from a DB, do something complex, etc… then you should probably use RenderAction.

I have a News controller responsible for news objects. I created a Block action, which will render a block with the latest news to be put in the home page. This is a perfect example, in my opinion, for RenderAction.

Leave a Comment