Migrate from Web Forms to MVC

Hybrid development

You can gradually migrate your Web Forms widgets to MVC widgets and Web Forms pages to MVC pages using the hybrid development approach - running both MVC and ASP.NET Core pages in the same project. Using hybrid type of pages, you can run both types of widgets on the same page. This way, you can use a step-by-step approach to migrate widgets and pages one at a time.

Migration mechanism

Migration of widgets from Web Forms to MVC is not a straight-forward operation. The two frameworks are different and manual work is required to achieve the migration.

In general, you need to:

  • Transfer all code contained within the ASPX code file to the newly defined controller method.
  • Any server-side validation procedures executed by Validation controls should be integrated into the new project.
  • The code associated with events triggered by the page must be disconnected.

Use the following guidelines to migrate the widget components:

Migrate the frontend widget component

The primary component of the Web Forms widget is the control itself. It represents the frontend functionality that the enduser interacts with on the website.

It is defined either as a standard user control (.ascx) and its associated code-behind file (.cs) or a custom control (.dll) and its associated template file (.ascx).

You need to migrate:

  • The markup (.ascx)
  • The server-side functionality (.cs)
  • The client-side functionality (.js)

Migrate the widget designer

All the backend functionality that the user uses to set the Web Forms widget properties is called control (widget) designer. The default Web Forms widget designer displays all public properties of the widget as input fields.

You need to migrate the following elements of the control designer:

  • Control designer class
    This is the class file that defines the control designer and is used to wire-up all of the designer elements. It must inherit from the ControlDesignerBase class.
  • Control designer template
    The template is an .ascx file that represents the actual editor that is displayed to the user. It is made up of standard HTML elements that are mapped to the properties of the widget.
  • Control designer JavaScript file
    Control designers use JavaScript to pass information from the widget to the editor template and to persist the changes from the editor template back to the widget. 

MVC designers are written in AngularJS and they use automatically generated widget designers. 
For more information, see Autogenerated field types.

Migrate the forms widgets

If your project uses forms, you need to migrates the forms widgets as well.
To migrate Web Forms forms widgets to MVC forms widgets, see Migrate Web Forms forms to MVC forms.

Want to learn more?

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?

Next article

Migration case studies