Tips for converting existing ASP.NET applications to ASP.NET Core
Tags: aspnetcore, monolith, microservices
Published: 2022-11-07 01:40:57

---
title: Tips for converting existing ASP.NET applications to ASP.NET Core
published: true
date: 2022-10-31 02:26:41 UTC
tags: ASPNETCore,monolith,microservices
canonical_url: https://coderethinked.com/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](https://manning.com/books/asp-net-core-in-action-third-edition?utm_source=coderethinked&utm_medium=affiliate&utm_campaign=book_lock3_asp_9_29_22&a_aid=coderethinked&a_bid=7a3c9ce3), 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](https://dev.to/karthikchintala/asp-net-core-and-benefits-1838-temp-slug-3049008) 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](https://manning.com/books/asp-net-core-in-action-third-edition?utm_source=coderethinked&utm_medium=affiliate&utm_campaign=book_lock3_asp_9_29_22&a_aid=coderethinked&a_bid=7a3c9ce3)

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

## Transitioning 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](https://github.com/FritzAndFriends/BlazorWebFormsComponents) 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 by andrew lock](https://coderethinked.com/wp-content/uploads/2022/10/aspnetcore-in-action-andrew-lock.jpg)](https://manning.com/books/asp-net-core-in-action-third-edition?utm_source=coderethinked&utm_medium=affiliate&utm_campaign=book_lock3_asp_9_29_22&a_aid=coderethinked&a_bid=7a3c9ce3)
_ASP.NET Core In Action, Third edition_

## Transitioning from the WCF application

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](https://github.com/dotnet/wcf) (part of the .NET foundation) and the [server-side](https://github.com/corewcf/corewcf) (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.

## Transitioning from MVC

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.

![aspnet core in action](https://coderethinked.com/wp-content/uploads/2022/10/aspnetcoreinaction-meap-edited.png)

### 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.

[Read Now<svg xmlns="https://www.w3.org/2000/svg" viewbox="0 0 512 512"><path d="M504.3 273.6l-112.1 104c-6.992 6.484-17.18 8.218-25.94 4.406c-8.758-3.812-14.42-12.45-14.42-21.1L351.9 288H32C14.33 288 .0002 273.7 .0002 255.1S14.33 224 32 224h319.9l0-72c0-9.547 5.66-18.19 14.42-22c8.754-3.809 18.95-2.075 25.94 4.41l112.1 104C514.6 247.9 514.6 264.1 504.3 273.6z"></path></svg>](https://manning.com/books/asp-net-core-in-action-third-edition?utm_source=coderethinked&utm_medium=affiliate&utm_campaign=book_lock3_asp_9_29_22&a_aid=coderethinked&a_bid=7a3c9ce3)

## 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](https://devblogs.microsoft.com/dotnet/announcing-yarp-1-0-release/) (a reverse proxy for .NET) and also ASP.NET [Migration Tooling in Visual Studio](https://devblogs.microsoft.com/dotnet/incremental-asp-net-migration-tooling-preview-2/) to help implement the [strangler fig](https://learn.microsoft.com/en-us/azure/architecture/patterns/strangler-fig) pattern.

![](https://learn.microsoft.com/en-us/azure/architecture/patterns/_images/strangler.png)
_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](https://manning.com/books/asp-net-core-in-action-third-edition?utm_source=coderethinked&utm_medium=affiliate&utm_campaign=book_lock3_asp_9_29_22&a_aid=coderethinked&a_bid=7a3c9ce3) 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..

[Read Now<svg xmlns="https://www.w3.org/2000/svg" viewbox="0 0 512 512"><path d="M504.3 273.6l-112.1 104c-6.992 6.484-17.18 8.218-25.94 4.406c-8.758-3.812-14.42-12.45-14.42-21.1L351.9 288H32C14.33 288 .0002 273.7 .0002 255.1S14.33 224 32 224h319.9l0-72c0-9.547 5.66-18.19 14.42-22c8.754-3.809 18.95-2.075 25.94 4.41l112.1 104C514.6 247.9 514.6 264.1 504.3 273.6z"></path></svg>](https://manning.com/books/asp-net-core-in-action-third-edition?utm_source=coderethinked&utm_medium=affiliate&utm_campaign=book_lock3_asp_9_29_22&a_aid=coderethinked&a_bid=7a3c9ce3)

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](https://manning.com/books/asp-net-core-in-action-third-edition?utm_source=coderethinked&utm_medium=affiliate&utm_campaign=book_lock3_asp_9_29_22&a_aid=coderethinked&a_bid=7a3c9ce3)
2. [BlazorWebFormsComponents – Github](https://github.com/FritzAndFriends/BlazorWebFormsComponents)
3. [WCF Client Side](https://github.com/dotnet/wcf)
4. [WCF server side](https://github.com/corewcf/corewcf)
5. [Microsoft .NET Framework Lifecycle](https://learn.microsoft.com/en-us/lifecycle/products/microsoft-net-framework)
6. [Strangler Fig Pattern](https://microservices.io/patterns/refactoring/strangler-application.html)


The post [Tips for converting existing ASP.NET applications to ASP.NET Core](https://coderethinked.com/tips-for-converting-existing-asp-net-applications-to-asp-net-core/) appeared first on [Code Rethinked](https://coderethinked.com).