How Sitecore MVC differs from ASP.NET MVC?
Enterprise application development is a topic that has been gaining more prominence as a key area of discussion. Perhaps the most common challenge faced by enterprise developers today is the need to enable seamless communication between business and development for ultimate project success. In order to work towards this goal, enterprise developers work on architectural frameworks, more commonly referred to as technologies. One of the most common architectural formats or industry-standard web development frameworks to create scalable and extensible projects is the MVC (Model-View-Controller) framework. The MVC Framework is built on top of ASP.NET and provides a large set of added functionality relying on component-based development and testing.
To understand the primary differences between Sitecore MVC and ASP.net MVC frameworks, it is first necessary to place it on a common ground and define MVC, since it forms the primary basis of comparison. This leads one to understand that, on a very basic level, Sitecore MVC is essentially an additional layer of API built on ASP.net. As one of the leading enterprise-level content management systems built on ASP.net, the primary purpose of these technologies or frameworks is to enable web editors and e-marketers to organize their websites in a way that allows them to take complete control over significant aspects of their websites such as social media integration and advanced personalization.
Sitecore MVC is slightly different from the conventional ASP.net MVC, but the basic concept remains the same. Let’s compare the two on specific terms.
- Request correspondence: In ASP.net MVC a request always corresponds to an MVC route. This means that there is only one controller and one corresponding action involved. To elaborate, ASP.net has a single controller which is being instantiated to which one action is being invoked. On the other hand, in Sitecore MVC a request usually corresponds to a Sitecore item. Focusing on Sitecore Controller Renderings means that multiple controllers can be used during one request, where multiple actions are invoked.
- Asynchronous controllers: While standalone ASP.net MVC supports asynchronous controllers, the same cannot be said of Sitecore MVC.
- Layout pages:net master pages are not particularly useful as a standalone option but may be used with Sitecore. Sitecore’s layout details are superior with the layout defined in the presentation details of the item.
- Implementation: Traditional ASP.net implementation offers techniques such as filters to implement features while Sitecore provides a feature called pipelines to assist development.
- Multiple forms: In ASP.net MVC, each form is posted to a specific controller or action. However, on Sitecore MVC, a form is usually posted to the same URL, allowing you to return the same item again. As a result of this, every action on each of your controllers is executed, without particularly considering whether it is the form that has been submitted. This can be resolved by opting to use the Sitecore Form handler to post your form to a specific controller.
- Access to data: The developer has to manually establish any context to access data in ASP.net MVC. Sitecore invokes specific pipelines to establish a processing context for data, which contains specific layout details of the various presentation components to be invoked. This way, Sitecore provides a data repository that is typically accessed through the context item.
- Registering routes: In traditional ASP.net MVC, developers use global.asax or other similar methods to register routes. Sitecore provides a default route to process items that specify layouts or controllers. Developers can implement pipeline processors to register components. Sitecore has a few limitations when it comes to multiple presentations of data; only one set of design details can be defined on an item.
Specific Sitecore functions
As already mentioned, Sitecore MVC has an additional layer of API that is very powerful. As a result of this, Sitecore items can be queried using a several methods/technologies, from standard .NET web forms to using MVC. Besides, Sitecore comes up with its own query languages, namely the Sitecore Query and Sitecore Fast Query.
Sitecore MVC provides ample flexibility, scalability and security. It has the ability to scale up to increasing demand and has been the most preferred enterprise solution for tech giants such as Microsoft to financial powerhouses such as American Express.