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.