• Home
  • SEO
  • Web
      Web Design Tools
    • Web
    • ASP.NET
    • Javascript
    • JQuery
    • JSP
    • Sitecore
    • ColdFusion
  • CAD
      Computer Aided Design
    • CAD
    • Media
    • Robot
  • Programming
      Programming Languages
    • DotNet
    • C#
    • VB
    • Java
    • Python
  • Database
      Database Systems
    • SQL
    • MySql
    • Oracle
    • Data Model
    • XML
    • Exchange
  • Tool
      Computer Tools
    • Tool
    • Power BI
    • Matlab
    • Statistics
    • Report
    • Office
    • Access
  • OS
      Operating System
    • OS
    • Solr
    • UNIX
    • SMTP
    • GL
  • Logic
      Computer Logic
    • Logic
    • Algorithm
    • Graph
  • Tips
      Computer Tips
    • Tips
    • Graphics

Sitecore View Rendering

A view rendering consists of a view that takes a RenderingModel by default. The model is assembled by the Sitecore MVC pipeline, and you can create your own, custom models. Because the pipeline expects an Initialize() method on your model, you can either inherit from RenderingModel or implement IRenderingModel.

Pros

They are simple to use – especially if you do not use a custom model.

Cons

If you need to do any business logic when retrieving your model, you will want to do that in a separate layer. However, because you do not have access to a controller, the only place you can do this logic is in the Initialize() method of a custom model – and putting business logic in the model itself is not ideal.

It’s just not very ASP.NET MVC. Developers are used to having a controller and an action, and view renderings do not work like that. However, you must keep in mind that Sitecore MVC is an implementation of ASP.NET MVC that needs to suppor the same features as its Web Forms counterpart

Sitecore controller Rendering

Rather than specifying a view, the component definition item for a controller rendering specifies a controller name and an action name. When the rendering is added to a placeholder, this action is executed and the view is returned.

Pros

They look ASP.NET MVC. You can use dependency injection and common patterns (like the repository pattern) as you normally would, and create your own actions.

Keeps your business logic separate from your model; you can create plain POCO classes that are hydrated by a business logic layer.

Cons

In some instances, a controller rendering is a lot of unnecessary work.

Sitecore MVC

Sitecore MVC - View Renderings vs Controller Renderings

Facebook LinkedIn Twitter
Privacy Policy
©2022