For developers: MVC modes
Sitefinity CMS supports three MVC modes. The following sections describe each mode.
Classic (bypass the Sitefinity CMS engine and directly use native controllers)
Classic mode is functionally equivalent to ASP.NET MVC. You can take regular controllers that you’ve implemented in a non-Sitefinity CMS ASP.NET MVC project, include them in the Sitefinity CMS project, and register routes that use them. This mode lets you reuse a lot of legacy code that you may want to move from a regular application to a Sitefinity CMS application. In this mode, you don’t work with Sitefinity CMS pages at all.
You can read a detailed description of how you can use the classic mode in For developers: Classic MVC mode.
Pure (multiple controllers per page, page is either MVC or WebForms)
The Pure mode lets you use MVC controllers and views as widgets on a Sitefinity CMS page. There is one major functional difference between pure and classic modes – you can use multiple controllers on the same page. Each controller becomes a widget on the page and is responsible for rendering a portion of it. However, you cannot use normal WebForms widgets on such a page.
You can read a detailed description of how you can use Pure mode in For developers: Pure MVC mode.
Hybrid (Mix MVC and WebForms on the same page)
The hybrid mode goes even further than pure mode and lets you mix WebForms and MVC widgets on the same page. It has to keep all WebForms related markup to enable ViewState, but it can also render the output of MVC controllers. There is one limitation – in your MVC controllers, you cannot use the regular BeginForm helper, but should use the Sitefinity CMS helper instead. The reason is that the WebForms model can only allow a single form on the page.
You can read a detailed description of how you can use Hybrid mode in For developers: Hybrid MVC mode.
Mode comparison table
Mode ->
|
Classic
|
Pure
|
Hybrid
|
Uses a SF page
|
No
|
Yes
|
Yes
|
Uses ViewState (clean markup)
|
No
|
No
|
Yes
|
Controllers per page
|
1
|
Many
|
Many
|
Form helper
|
@Html.BeginForm
|
@Html.BeginForm and @Html.BeginFormSitefinity
RECOMMENDATION: We recommend that you use the @Html.BeginFormSitefinity helper since it ensures that you can use your widget on both hybrid and pure pages.
|
@Html.BeginFormSitefinity
|
Route registration
|
Manual
|
Auto
|
Auto
|
Which mode should I use?
The mode used depends on your development process as well as the functionality you want to implement.
- If you want clear markup, a lot of client code and are willing to sacrifice the ViewState and postback model, use Pure mode.
- If you want to use the built-in Sitefinity CMS MVC widgets, together with Web Forms widgets on the same page, you have to use the hybrid mode.
- If you are porting an existing MVC app into Sitefinity, and want precise control over your URLs, you may want to use the classic mode.
Those are not the only scenarios and there are always tradeoffs to be made.