Migrate from Web Forms to ASP.NET Core
Hybrid development
You can gradually migrate your from Web Forms to ASP.NET using the hybrid development approach - running both Web Forms and ASP.NET Core pages in the same project. This way, you can use a step-by-step approach to migrate widgets and pages one at a time.
This is possible, because the ASP.NET Core Renderer does not limit you to create and edit only ASP.NET Core pages. Using the Renderer, you can work with ASP.NET Core or Web Forms. This means that, in each site, you can have a mixed collection of both supported rendering mechanisms.
However, rendering ASP.NET Core widgets in Web Forms based pages or vice versa is not possible.
Migration mechanism
Migration of widgets from Web Forms to ASP.NET Core is not a straight-forward operation. The two frameworks are different and manual work is required to achieve the migration.
Use the following guidelines to migrate the widget components:
Migrate the frontend Web Form 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)
For more information about the ASP.NET Core widget components that you need to map your Web Forms logic and presentation, see Widget fundamentals.
Migrate the Web Forms widget designer
All the backend functionality that the user uses to set the 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 inherits 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.
ASP.NET Core designers use automatically generated widget designers. You need to migrate the logic from the elements above to the respective field types and properties.
For more information, see Autogenerated field types.
Frontend authentication
Having the Default or OpenID authentication protocol configured for Sitefinity, enables the Renderer and Sitefinity CMS to be in a Single Sing On (SSO) scenario, as well as Single Sign Out. This means that when you log in Sitefinity CMS, this automatically logs you in the Renderer app.
For example, the login form on an MVC-based page automatically logs the user to the ASP.NET Core Renderer or vise versa.
The biggest benefit here is that when a user requests a ASP.NET Core page the HttpContext.User
property in the ASP.NET Core Renderer app is properly configured with the ClaimsIdentity
of the logged user. Because this is valid for only the GET
requests that are related to rendering Sitefinity pages, if you want, you can to add it to any other request, such as form post to a custom controller.