Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practise to migrate Web Forms to ASP.NET Core MVC

I am trying to migrate a project from classic ASP.Net Web Forms to ASP.NET MVC.

While I have read through http://www.codeproject.com/Articles/38778/ASP-NET-WebForms-and-ASP-NET-MVC-in-Harmony. I have a basic idea on how the code structure, libraries and routing should be done.

For your information, the scope of my existing project is around 400 pages and 300 tables.

On top of my head I have two approaches:

  1. Start from stretch, rewriting the whole system - Obviously this would require intensive work and take a long time. Any change made on existing system would need a duplicate change made to the new system.
  2. Migrate the page one each - I still have a rebuild the entire core library (for accessing db), and get the page migrated one by one. For this I would assume to have two core libraries (new and old) running simultaneously with different pages connect to one of those.

Would anyone have similar experience and advise a proper way to start?

For this complete revamp I may also target at the latest technology - .NET Core and MVC6, by taking these would I have extra advantage, or some blockages I would have to take care of?

Any suggestion and opinions are appreciated. Cheers.

like image 569
ydoow Avatar asked Jun 28 '16 02:06

ydoow


People also ask

Can Web forms run on .NET Core?

ASP.NET Web Forms isn't supported in ASP.NET Core (nor are ASP.NET Web Pages). Typically, the functionality of these pages must be rewritten when porting to ASP.NET Core. There are, however, some strategies you can apply before or during such migration to help reduce the overall effort required.

What is the equivalent of web forms in ASP.NET Core?

ASP.NET Core Razor Pages is the natural successor to the traditional Web Forms development framework.

Should I migrate to ASP.NET Core?

NET core is considered hands down the better performer over the traditional . NET Framework, as it provides high-performance server runtime. Scalability comes into question when we work across systems also while working with Cloud. Cloud-native modernization for SMBs require significant revamp of the existing software.


2 Answers

Microsoft is a bit hush hush on the subject but the WebForms engine is probably never going to make its way to ASP.NET Core. One might think that MS is waiting to see if the community is calling for a port, but I think they're trying to kill it discretely (not like Silverlight).

Why? Because it proved to be a bad good idea on the long run, easy to use at first, but extremely complex to master (because of viewstate and page lifecycle), with a tendency to allow average developers to build very tedious application (in french we say steam factories). Also it was very poorly adapted to modern web development (Ajax, unit testing, IoC). They tried to fix it with a couple of tweaks, but the overall architecture is just not adapted to this kind of things. MVC is a treat in comparison!

To answer your question, it's not really possible to migrate WebForms to MVC, because those are quite different architectures, and of course the architecture is what an application sits on top on, so if you change it, you might as well rewrite it from scratch.

What can help you a lot is if your app is divided in tiers (business, data access, UI). If it's not the case, you could start by doing this, properly separating the UI project from the rest. Then you would just have to rewrite the ASP.NET project and not the rest.

like image 97
François G. Avatar answered Oct 18 '22 19:10

François G.


There are some useful resources I'd like to share with the StackOverflow community just in case you are having troubles to decide what to do:

  • modernization of your existing Web Forms app
  • migration to MVC or Core
  • or whether to start a new project on Web Forms, MVC and Core.

Here you go:

  • https://www.telerik.com/blogs/review-of-telerik-toolsets-for-aspnet-web-forms-core
  • Modernizing ASP.NET Web Forms Applications by Tomáš Herceg (Microsoft MVP ) - https://tomasherceg.com/blog/post/modernizing-asp-net-web-forms-applications-part-1
  • Migrating Old ASP.NET Applications to .NET Core by Edi Wang (Microsoft MVP) - https://edi.wang/post/2018/10/31/migrating-old-aspnet-applications-to-net-core
  • Choose between ASP.NET and ASP.NET Core (Microsoft docs) - https://learn.microsoft.com/en-us/aspnet/core/fundamentals/choose-aspnet-framework?view=aspnetcore-3.1
  • Migrate from ASP.NET to ASP.NET Core (Microsoft docs) - https://learn.microsoft.com/en-us/aspnet/core/migration/proper-to-2x/?view=aspnetcore-3.1
like image 2
Rumen Jekov Avatar answered Oct 18 '22 19:10

Rumen Jekov