Migrating Your Legacy ASP.NET Projects to ASP.NET Core Incrementally with YARP

This blog is presented as a part of C# Advent 2023. Follow the link to check out the rest of the excellent C# and .NET content coming out as 2 blogs per day between December 1 - 25.

Many C# and .NET developers are grappling with aging ASP.NET projects still running on the .NET Framework. If that’s you, you’re not alone. Many of us have invested heavily in these applications, so the prospect of a full-scale upgrade can seem overwhelming. You might have your eye on moving to ASP.NET Core with its array of features and performance enhancements, but how do you get there? Do you have to do it all at once or is there a gradual way?

In this article, we’ll explore an incremental approach to migrating your legacy ASP.NET projects to ASP.NET Core. We’ll introduce you to a powerful tool called YARP (Yet Another Reverse Proxy), which can facilitate this process and make it more manageable, and a Visual Studio extension called the .NET Upgrade Assistant that will help you through the process.

The Challenge of Migration

The challenge with upgrading large ASP.NET applications lies in the fact that they’re often built on a .NET Framework, and transitioning them to ASP.NET Core involves significant effort. The substantial improvements in ASP.NET Core, while highly beneficial, also introduce breaking changes that make the upgrade process more complex than other types of projects.

The “big bang” approach of locking a team in a room until the entire application is upgraded is rarely a practical option, especially for larger projects. It’s not at all agile, more prone to errors, and can lead to frustration among team members.

Another viable approach is the evolutionary method, which involves refactoring the application in waves. This incremental process allows for adjustments, refactoring, and continuous improvement. However, coordinating this with production releases can be a challenge.

The Strangler Fig Approach

Enter the “strangler fig” pattern, inspired by a plant by the same name that germinates in the canopy of trees, grows vines down the tree, and wraps around its roots, eventually killing the tree and using it as a backbone to reach the sunshine.

This tactic used by nature, though violent, makes for a good analogy for gradual migrations of software projects. Using the strangler fig approach involves setting up a facade layer that brings together the old and new applications under one roof. The front-end interface remains stable, while the backend gradually transitions to ASP.NET Core. Eventually, the legacy application is entirely replaced, and the facade layer can be removed.

Meet YARP: Yet Another Reverse Proxy

YARP is a customizable reverse proxy built on top of ASP.NET Core and .NET. Developed by Microsoft, it’s tailored for .NET developers and seamlessly integrates with ASP.NET Core applications. Because it integrates with ASP.NET Core, YARP runs smoothly on Windows, Linux, MacOS, and in containers, and adding it to your project is as simple as installing a NuGet package.

Whie it can be used for many different purposes, YARP is perfect for implementing the strangle fig pattern to migrate a legacy ASP.NET application to ASP.NET Core. It allows you to gradually migrate your application while using the proxy to unite the two apps into one apparent app to your end-user. As you can see below, YARP becomes your facade layer but runs completely within your modern app.

Understanding Reverse Proxies

A reverse proxy, in essence, does the opposite of what a regular (forward) proxy does. Instead of forwarding requests from the local network out into the internet, a reverse proxy forwards requests from clients on the internet into one or more servers on your network (or your cloud provider’s network).

In the context of YARP being used for legacy migrations, this allows requests to be directed to either the legacy ASP.NET application or the new ASP.NET Core application based on what endpoints exist and your configuration settings.

Migration Tooling

A tool that can be very helpful when doing any migration in .NET is the .NET Upgrade Assistant. It streamlines the process of many different times of upgrade projects, including ASP.NET. For our purposes, it can help you automate the setup of your existing ASP.NET app, YARP, and a new modern ASP.NET Core project. It also helps you throughout your gradual code migration process by tracking your progress and helping you move controllers and other classes from your legacy ASP.NET project to the new ASP.NET Core project. While some manual adjustments may be needed, this tool saves you significant time and effort by streamlining and tracking the migration process for you.

Migration Steps

  1. Install the .NET Upgrade Assistant Visual Studio extension. You can find more information on how to install it here.
  2. Open your ASP.NET project in Visual Studio.
  3. In the Solution Explorer window, right-click on the project you want to upgrade and select Upgrade.
  4. Select Side-by-side incremental project upgrade, which is the only upgrade option available for upgrading from ASP.NET to ASP.NET Core with YARP.
  5. For the upgrade target, select New project if you want it to create a new one for you, otherwise Existing project if you already have one, then click Next.

After following these steps, the .NET Upgrade Assistant will put a new ASP.NET Core project next to your existing ASP.NET legacy project and sets up YARP to route any endpoints that are implemented in the new project there, while all other calls are sent to the legacy ASP.NET application.

This mode lets you slowly upgrade your ASP.NET app piece-by-piece to the new ASP.NET Core app without even having to make configuration changes throughout the process. You can deploy these apps many times throughout the migration process, allowing you to follow an agile process for your migration.

At any time during the migration project, you can right-click on the legacy ASP.NET project in Solution Explorer to get a status report of your migration progress or to use tooling to help you automatically migrate classes and controllers to the ASP.NET Core project.

Conclusion

Migrating your legacy ASP.NET projects to ASP.NET Core is a crucial step toward harnessing the full potential of modern web development. With YARP and the incremental strangler fig approach, this transition becomes manageable, allowing you to leverage the benefits of ASP.NET Core without the need for a massive overhaul.

Don’t let the complexity of migration hold you back. Embrace the power of gradual ASP.NET migrations using the .NET Upgrade Assistant and YARP, unlocking a new era of possibilities for your applications.

If you need help with this process, contact Trailhead and we can guide you through your legacy migration project safely and smoothly.

Related Blog Posts

We hope you’ve found this to be helpful and are walking away with some new, useful insights. If you want to learn more, here are a couple of related articles that others also usually find to be interesting:

Our Gear Is Packed and We're Excited to Explore With You

Ready to come with us? 

Together, we can map your company’s software journey and start down the right trails. If you’re set to take the first step, simply fill out our contact form. We’ll be in touch quickly – and you’ll have a partner who is ready to help your company take the next step on its software journey. 

We can’t wait to hear from you! 

Main Contact

This field is for validation purposes and should be left unchanged.

Together, we can map your company’s tech journey and start down the trails. If you’re set to take the first step, simply fill out the form below. We’ll be in touch – and you’ll have a partner who cares about you and your company. 

We can’t wait to hear from you! 

Montage Portal

Montage Furniture Services provides furniture protection plans and claims processing services to a wide selection of furniture retailers and consumers.

Project Background

Montage was looking to build a new web portal for both Retailers and Consumers, which would integrate with Dynamics CRM and other legacy systems. The portal needed to be multi tenant and support branding and configuration for different Retailers. Trailhead architected the new Montage Platform, including the Portal and all of it’s back end integrations, did the UI/UX and then delivered the new system, along with enhancements to DevOps and processes.

Logistics

We’ve logged countless miles exploring the tech world. In doing so, we gained the experience that enables us to deliver your unique software and systems architecture needs. Our team of seasoned tech vets can provide you with:

Custom App and Software Development

We collaborate with you throughout the entire process because your customized tech should fit your needs, not just those of other clients.

Cloud and Mobile Applications

The modern world demands versatile technology, and this is exactly what your mobile and cloud-based apps will give you.

User Experience and Interface (UX/UI) Design

We want your end users to have optimal experiences with tech that is highly intuitive and responsive.

DevOps

This combination of Agile software development and IT operations provides you with high-quality software at reduced cost, time, and risk.

Trailhead stepped into a challenging project – building our new web architecture and redeveloping our portals at the same time the business was migrating from a legacy system to our new CRM solution. They were able to not only significantly improve our web development architecture but our development and deployment processes as well as the functionality and performance of our portals. The feedback from customers has been overwhelmingly positive. Trailhead has proven themselves to be a valuable partner.

– BOB DOERKSEN, Vice President of Technology Services
at Montage Furniture Services

Technologies Used

When you hit the trails, it is essential to bring appropriate gear. The same holds true for your digital technology needs. That’s why Trailhead builds custom solutions on trusted platforms like .NET, Angular, React, and Xamarin.

Expertise

We partner with businesses who need intuitive custom software, responsive mobile applications, and advanced cloud technologies. And our extensive experience in the tech field allows us to help you map out the right path for all your digital technology needs.

  • Project Management
  • Architecture
  • Web App Development
  • Cloud Development
  • DevOps
  • Process Improvements
  • Legacy System Integration
  • UI Design
  • Manual QA
  • Back end/API/Database development

We partner with businesses who need intuitive custom software, responsive mobile applications, and advanced cloud technologies. And our extensive experience in the tech field allows us to help you map out the right path for all your digital technology needs.

Our Gear Is Packed and We're Excited to Explore with You

Ready to come with us? 

Together, we can map your company’s tech journey and start down the trails. If you’re set to take the first step, simply fill out the contact form. We’ll be in touch – and you’ll have a partner who cares about you and your company. 

We can’t wait to hear from you! 

Thank you for reaching out.

You’ll be getting an email from our team shortly. If you need immediate assistance, please call (616) 371-1037.