Announcing DotVVM Adapters for ASP.NET Web FormsPublished: 7/8/2018 4:20:11 PM
Today, we have released a first preview of DotVVM.Adapters.WebForms package to the official NuGet. This package provides a basic support for hosting DotVVM pages in old ASP.NET Web Forms applications.
Why do we care about Web Forms in 2018?
There are thousands of companies that still rely on legacy ASP.NET applications. These apps are often more than 10 years old, and there is no easy way of rewriting them. They still need to be updated and there are still new features required. It is hard, or even impossible to rebuild these applications from scratch in newer technologies. It would take years to recreate all functionality and it would probably require more people – some of them would still have to maintain the old project and share the know-how with the other team which would be building the new solution.
Moreover, we have seen many Web Forms applications using the SqlDataSource approach, which means that the business logic is not separated in its own layer. That makes rewriting of the application even more complicated – basically, you need to rewrite everything as there is no proper business layer that could be reused.
Modernize ASP.NET Web Forms applications
First versions of DotVVM were built for classic ASP.NET (because there was no ASP.NET Core at that time) and even today, about 80% of DotVVM projects are still created with OWIN and .NET Framework. OWIN was the official way to combine multiple frameworks in a single ASP.NET application, and that’s how the DotVVM integration with ASP.NET Web Forms works.
Our Web Forms integration package allows to install DotVVM in existing ASP.NET applications and build new pages in DotVVM, or rewrite current ASPX pages with DotVVM ones. The old pages will keep working. The application will be deployed the same way as before, and hosted on the same server with no configuration changes – it is still the same ASP.NET app, there is few extra NuGet packages installed in it.
Over time, you may get rid of all ASPX pages – some will be replaced with DotVVM ones, some might retire if their functionality is not needed any more. When there are no ASPX pages left in the project, you may even be able to migrate the project to .NET Core and take advantage of the great benefits .NET Core offers. DotVVM is supported on .NET Core and works the same way.
Of course, some features from .NET Framework are not available on .NET Core yet (WCF or Entity Framework 6 for example), but it may change.
And even if the migration to .NET Core is not possible, there are still many benefits of DotVVM that can be interesting for ASP.NET Web Forms developers – cleaner architecture, testability, nicer HTML outputs, two-way data-binding and client-side interactivity, REST API integration and much more.
Check out this cheat-sheet so you can see how the same things are done in ASP.NET Web Forms and in DotVVM.
How to start
There are a few steps that need to be done:
1. Open the csproj file and add change the
<ProjectTypeGuids> element to the following code:
2. Install the DotVVM.Adapters.WebForms package in your ASP.NET project.
DotvvmStartup.cs classes (see sample app).
4. Add the following registration to
<system.web> <pages> <controls> <add tagPrefix="dotvvm" namespace="DotVVM.Adapters.WebForms.Controls.WebForms" assembly="DotVVM.Adapters.WebForms"/> </controls> </pages> </system.web>
5. Create a DotVVM Master Page and make it look the same as the Web Forms one. Use the same CSS files and the same structure of elements.
<webforms:RouteLink> in the DotVVM master page to create links to ASP.NET Web Forms routes (in the menu and so on).
7. Create your first DotVVM Page and register a route for it.
<dotvvm:RouteLink runat="server"> control in ASP.NET Web Forms pages to create a link to DotVVM routes.
9. The authentication should just work – DotVVM and ASP.NET pages should see the same user identity. If you are using Membership providers and Forms authentication, we strongly recommend to replace it with OWIN Security middlewares. You can read more information in Modernizing ASP.NET Web Forms Applications blog post series written by Tomas Herceg.
Now you should have fully functional ASP.NET and DotVVM pages in the same application. You can replace old pages with the new ones, or you can just write new pages with DotVVM. If your business logic is not hidden in ASP.NET views, you can reuse it from DotVVM quite easily.
If you are using SqlDataSources (or other declarative way of data-binding), you should consider adding a new class library project for a proper business layer. Take this as an opportunity to clean up your old application, to add new pieces of architecture, and do as many improvements to the solution as possible.
We are thinking about adding more features to the Web Forms integration package – for example the control which could host DotVVM user controls in ASP.NET Web Forms pages, and a few other things. We’d love to hear from you – tell us if this package interesting for you and what features would help you to modernize your ASP.NET Web Forms projects.
I am the CEO of RIGANTI, a small software development company located in Prague, Czech Republic.
I am Microsoft Most Valuable Professional and the founder of DotVVM project.