Guidelines for migrating widgets from MVC to .NET Core

Overview

Migration of widgets between the MVC framework and the .NET Core widget framework is not a straight-forward operation. The two frameworks are different, and some manual work is required to achieve the migration. 

For more information, see Migrate your pages to .NET Core.  

In general, the View and ViewModel classes must not contain any logic. Therefore, you can easily copy and migrate them from the MVC to the .NET Core widgets.  

  • There are some differences in the APIs for referencing scripts.  
    For more information, see Client-side development for the .NET Core framework.  

  • To configure the HTML sanitization API, use the HTML sanitizer sample on Sitefinity’s GitHub repository, located at HTML sanitizer.
    For more information about using the sanitizer, see LongText.cshtml on Sitefinity’s GitHub repository. 

Migrate the Controller class

The controller class logic is designed to connect the logic of the Model and the View. This is also true for the .NET Core ViewComponents as well. All OOB widgets listed in the following GitHub repository have no (or in rare cases, little) logic inside of them. Everything is placed in the Model classes. Alternatively, you can omit the Model class and place everything in the ViewComponent class. 

Migrate the Model class

The Model class is the most complex for migration because it heavily employs content APIs. In this case, there is no straightforward approach, so migration must be done case-by-case.  

For more information about fetching and displaying content, see Query content.

Migrate the designers

MVC designers are written in AngularJS. The .NET Core framework uses automatically generated widget designers. These designers are also supported by MVC widgets. Thus, the recommended approach is to first migrate to the autogenerated designers, so you can easily switch the framework going forward.  

For more information, see Autogenerated field types

 

 

 

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?