ASP.NET Core

Tips for converting existing ASP.NET applications to ASP.NET Core

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

  1. Less scalable: Instead of scaling only the UI/API horizontally you may have to scale it vertically as it’s a monolith application
  2. The codebase may become huge overtime
  3. Deployment problems: Having to deploy a feature to larger codebases takes more time than deploying a small codebase.
  4. Difficult to test: Adding a small feature to the project may affect the whole system. A full regression is required.
  5. 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

  1. ASP.NET Web Forms
  2. Is built using WCF
  3. 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.

ASP.NET Core In Action, Third edition

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.

ASP.NET Core in Action (save 45% now)

Andrew Lock teaches you how you can use your C# and .NET skills to build amazing cross-platform web applications.

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.

Pic Credits: Microsoft Learning

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.

ASP.NET Core in Action (45% off)

This Andrew Lock’s revised bestseller reveals the latest .NET patterns, including minimal APIs and minimal hosting..

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

  1. ASP.NET Core In Action
  2. BlazorWebFormsComponents – Github
  3. WCF Client Side
  4. WCF server side
  5. Microsoft .NET Framework Lifecycle
  6. 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.

Disqus Comments Loading...
Share
Published by
Karthik Chintala

Recent Posts

2 Good Tools To Test gRPC Server Applications

In this post, we’ll see how to test gRPC Server applications using different clients. And… Read More

2 years ago

Exploring gRPC project in ASP.NET Core

In this post, we'll create a new gRPC project in ASP.NET Core and see what's… Read More

2 years ago

Run dotnet core projects without opening visual studio

In this blog post, we’ll see how to run dotnet core projects without opening visual… Read More

2 years ago

Programmatically evaluating policies in ASP.NET Core

Programmatically evaluating policies is useful when we want to provide access or hide some data… Read More

2 years ago

Multiple authorization handlers for the same requirement in ASP.NET Core

We saw how we could set up policy-based authorization in our previous article. In this… Read More

2 years ago

Policy-Based Authorization in ASP.NET Core

What is policy-based authorization and how to set up policy-based authorization with handlers and policies… Read More

2 years ago

This website uses cookies.