This blog post contains my perspective on contrasts between view and controller renderings in MVC solutions that use the Sitecore ASP.NET web Content Management System (CMS) and Experience Platform (XP). In many cases, you can use view renderings and controller renderings to achieve the same objectives, and the choice is a matter of preference. In other cases, one rendering technology may be more appropriate based on criteria including those discussed here. This blog post does not consider these constructs in the context of processing entire requests at the page/request level, but only these two types of renderings, and only at the presentation component level.
Sitecore MVC solutions support view renderings, which allow runtime binding of nested views to placeholders in existing views. Sitecore invokes the mvc.getModel pipeline to determine and construct the model to pass to the view as specified in the view definition item. It then passes that model to the class compiled from the .cshtml file specified in the view definition item.
Controller renderings function similar to view renderings in that they define presentation components for nesting within other components. With view renderings, the rendering engine invokes a .cshtml file; with controller renderings, the rendering engine invokes an action method in a controller class.
Logic in the action method of a controller renderings can invoke the View() method in the System.Web.Mvc.Controller base class, which in turn invokes a view. With this approach, the controller rendering functions much like a view rendering, but with at least two differences:
Due to the order of operations and for performance or other reasons, some logic may belong or function correctly only in the primary controller activated by the HTTP request rather than an individual controller rendering or view rendering. For example, the primary controller may be responsible for redirection. Again, this blog post does not attempt to account for these considerations at the request level, but only presentation at the component level.
If you have suggestions for when view renderings or controller renderings may be more appropriate, please comment on this blog post.
Very informative post
Thanks for reading and for the positive feedback!
"If you have suggestions for when view renderings or controller renderings may be more appropriate, please comment on this blog post.": View renderings are the sitecore equivalent of @HTML.Partial and Controller Rendering are the equivalent of a @HTML.Action. If you think of it that way the relative merits are well documented, not least of which here stackoverflow.com/.../mvc-html-partial-or-html-action
For everything I google about Sitecore, i will find John's posts as answers. Thanks for all your posts John. I have documented the steps involved in creating View rendering and controller renderings here View rendering - www.kewlcodes.com/.../View-rendering-in-sitecore-mvc-with-an-example. Controller rendering - www.kewlcodes.com/.../Controller-rendering-in-Sitecore-MVC-with-a-full-example