Develop with Sitefinity CMS and ASP.NET MVC
Sitefinity CMS multi-layer architecture is designed and built around the key concepts of extensibility, interoperability, integration, and flexibility. Sitefinity CMS provides you with choices of how to implement your logic and meeting your requirements, for example, working with third-party software and utilizing various approaches on how to solve a problem. The recommended approach is to work with ASP.NET MVC framework to build websites and interfaces, widgets, interactions, and applications. With MVC development, you have the following advantages:
- Full control over the whole markup
- You can extend the routes, controllers, filters, and actions in MVC and also to define your own HTML Helpers
- MVC widgets are automatically registered in the toolbox
- Controllers in MVC are decoupled from any state and can be easily tested and mocked
- Loosely coupled components that make parallel development possible for different components
- Performance is optimized since MVC is not coupled with ViewState
- MVC architecture pattern complements the SOLID principles
Developers with an MVC background can implement custom controllers and views that can be also used in a Sitefinity CMS project.
MVC controllers and Sitefinity CMS widgets
With Sitefinity CMS, you can leverage the classic and pure modes of MVC. The mode you use depends on your development process as well as the functionality you want to implement. The classic mode, as the name suggests, is the mode in which a page is represented by one controller (in essence, bypassing Sitefinity CMS page routes) – as it is outside of the context of Sitefinity CMS. The pure mode is Sitefinity-specific and brings ASP.NET MVC with a Sitefinity CMS implementation. Namely, controllers are interpreted as widgets, so you can build Sitefinity CMS widgets from controllers and have more than one controller within a page. For more information, see MVC modes.
- Directly register MVC code as Sitefinity CMS widgets
You can directly integrate your MVC code (models, views, and controllers) by adding a simple attribute to register your controller, so it becomes available to end users to place onto pages using drag and drop.
- Full Razor support
The MVC engine in Sitefinity CMS gives you full control over markup that your custom widgets generate, including full Razor support. You can build your views by using various template engines and, in addition, use Kendo UI framework.
- API that works for model binding in Sitefinity CMS
ASP.NET MVC exposes an API that allows you to easily perform any operation to any object controlled by the system, therefore allowing you to meet any user experience, functional, or integration requirement. In addition, the majority of the API methods work seamlessly with LINQ and return objects and collections that automatically bind to your Razor views.
- Control over routing
Sitefinity CMS works with the MVC routing engine, which provides rich features that allow you to control the URL structure of any resource out of the box. In the same time, you can use the convention-based routing within your controllers. In case you also need control over custom routes, you have full access to the Route Table.
- Dynamic data and dynamic content types
Sitefinity CMS Module Builder enables you to instantly create a data layer for any scenario. For any other content type requirement, all you need to do is define the meta fields that you need and Sitefinity CMS builds the content type and automatically provides the full infrastructure - back-end screens with media fields, taxonomy fields, many-to-many relationships and so on. In addition, Sitefinity CMS exposes the full API so you can use it in your MVC controllers.