The evolution of microservices greatly impacted how we think, write and manage applications in the cloud environment.
The existing monoliths are being migrated slowly to implement microservices and their patterns.
Scalability is one of the major aspects that developers/architects looking for migrating from ASP.NET Framework to ASP.NET Core.
I was reading the ASP.NET Core in Action, 3rd Edition, and found this chapter interesting on migrating existing asp.net applications to asp.net core. So, this blog post is about migrating.
Gist
In this post, we’ll see
- Drawbacks of monolith applications
- Challenges involved in converting ASP.NET Web Forms, MVC, and WCF to ASP.NET core applications
- When to convert an application to ASP.NET Core
Drawbacks of a monolith application
- Less scalable: Instead of scaling only the UI/API horizontally you may have to scale it vertically as it’s a monolith application
- The codebase may become huge overtime
- Deployment problems: Having to deploy a feature to larger codebases takes more time than deploying a small codebase.
- Difficult to test: Adding a small feature to the project may affect the whole system. A full regression is required.
- Tied to one technology: The choice of technology is limited to ASP.NET. If a problem can be solved easily with other technologies, with the asp.net framework or any monolith application you cannot do it
But, there are benefits of asp.net core that come along with migrating existing asp.net applications such as
- Cross-platform deployment
- Modularity
- Performance
However, converting the existing asp.net applications may involve additional cost and technical expertise to do that transition.
There are difficulties converting the following applications to asp.net core
- ASP.NET Web Forms
- Is built using WCF
- Is huge and uses advanced MVC features
Let’s see why it is difficult to transition the above use cases
Converting from ASP.NET Web Forms to ASP.NET Core
If the application is asp.net web forms, trying to convert it is not advisable as web forms are tied to System.Web.dll and IIS.
The conversion involves a complete rewrite of the app in ASP.NET Core.
It doesn’t mean your hopes of converting are dead at this point. There is a community-driven repository that guides on how to reuse much of the markup as in blazor.
Blazor server provides a component-based application that is similar to the web forms application model. So, you can convert web forms application gradually to asp.net core blazor application.
You can slowly transition the APIs into asp.net core web API application by reducing the reliance on the web forms concepts like ViewData.
Converting from the WCF application to ASP.NET Core
Windows Communication Foundation (WCF) is partially supported in ASP.NET Core. Again, it’s possible to build using the libraries for both the WCF client side (part of the .NET foundation) and the server-side (supported by the .Net foundation).
However, the above-mentioned libraries don’t support all of the APIs available in the .NET framework WCF. If you need all of them for sure, don’t migrate to ASP.NET Core for now.
Converting from ASP.NET MVC to ASP.NET Core
If an MVC application is complex and uses the extensive features of MVC like message handlers, then porting to ASP.NET Core will be more difficult.
Although ASP.NET Core is built with similar features as MVC, the underlying architecture is different as ASP.NET Core is written from scratch.
When to port an application to ASP.NET Core
If the existing application will need significant future development, then migrating to ASP.NET Core is a good choice.
If your application is rarely used and may not involve additional development efforts, then it’s better not to migrate to an ASP.NET Core application.
Microsoft will support .NET Framework for years to come (you may have to update the framework) though we have a new release of ASP.NET Core 7.
The best approach to migrating an ASP.NET core project is to start small and integrate with an existing application or start your new project as ASP.NET Core and integrate with an existing monolith.
It’s best to work in chunks rather than converting the entire application at once and Microsoft also provides YARP (a reverse proxy for .NET) and also ASP.NET Migration Tooling in Visual Studio to help implement the strangler fig pattern.
In the early migration, we see only a small portion of the modern application created in early migration and gradually most of the legacy system is migrated to the modern and then once the migration is complete we should have everything in the modern system.
Conclusion
ASP.NET Core applications offer modularity and performance at the same time. And they are best suited for microservices in the .NET ecosystem.
If your existing business is built on ASP.NET Framework and is working well and getting fruits for you then you don’t need to migrate to ASP.NET core.
Converting existing applications to asp.net core is possible but it involves planning, time, effort, and resources.
But, understanding the hard parts of the existing application is critical to transforming to an ASP.NET Core application. It helps to think about what it takes to convert the hard parts of the application first.
If you are creating a new product and the product really doesn’t need to be scalable for a huge number of users, you may not need to do it in ASP.NET Core. But, I’d recommend creating applications in ASP.NET Core now because .NET Framework may eventually retire sometime in the future and you may have to look up for ASP.NET Core again.
This article is sourced from a chapter in ASP.NET Core In Action, 3rd Edition written by Andrew Lock.
Andrew lock also gives a great insight into how the ASP.NET Core works and how it processes a request and many great things we can do with ASP.NET Core. It’s worth a read.
References
- ASP.NET Core In Action
- BlazorWebFormsComponents – Github
- WCF Client Side
- WCF server side
- Microsoft .NET Framework Lifecycle
- Strangler Fig Pattern
Collect your free eBook now
The first three users to utilize the below coupons will get a free eBook version of ASP.NET Core In Action, 3rd Edition by Andrew Lock. Here are the coupon codes
- aspcore-41AF
- aspcore-324C
- aspcore-5a31
Also, get 35% off on all books with this coupon code: blrethinked22
Disclaimer:
This post contains affiliate links.
Karthik is a passionate Full Stack developer working primarily on .NET Core, microservices, distributed systems, VUE and JavaScript. He also loves NBA basketball so you might find some NBA examples in his posts and he owns this blog.
Pingback: Dew Drop – October 31, 2022 (#3797) – Morning Dew by Alvin Ashcraft