📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

You own a large ASP.NET MVC 5 / .NET Framework 4.8 monolith that the business depends on, and you're asked to move it to .NET 10 and a modern architecture without stopping feature work. How do you plan the migration with the strangler fig pattern and YARP, slice it into increments, handle shared auth, session and data, and measure progress?

Incremental migration of a .NET Framework monolith to .NET 10: strangler fig with a YARP front, System.Web adapters for shared auth and session, choosing slices, data strategy, and measuring progress.

Senior RealWorldScenario Advanced architecture dotnet-framework legacy-migration strangler-fig system-web-adapters yarp

🎯 Key points

  • No big-bang rewrite: strangler fig routes traffic route by route from the old app to the new one
  • New ASP.NET Core 10 app in front with YARP (routing, load balancing, health checks, config reload); unmigrated routes are proxied to the .NET Framework app
  • Microsoft.AspNetCore.SystemWebAdapters share auth and session during the transition; secure the remote-app channel (HTTPS, API key in Key Vault, not internet-exposed) and treat it as temporary
  • Remote session and auth add a network hop per request: measure the overhead, keep session payloads small, and plan the end state (OIDC with Entra ID, stateless APIs)
  • Pick slices by value and risk: low-coupling, high-change or high-pain routes first; avoid the scariest core first
  • Data: keep one database at first, move to module ownership later; don't migrate code and data in the same step
  • Monitor both apps as one: OpenTelemetry/Application Insights with W3C trace context through YARP, per-route p95 and error rate against the legacy baseline, feature-flag rollback per route

⏱ 30-second answer

I wouldn't rewrite it. I'd use the strangler fig pattern: put a new ASP.NET Core 10 app in front, with YARP proxying every route it doesn't handle yet to the old .NET Framework 4.8 app. Then I move features route by route, starting with slices that are valuable and loosely coupled, while the team keeps shipping.

The tricky parts are shared state: I use System.Web adapters to share authentication and session between the two apps, multi-target shared libraries to .NET Standard 2.0, and keep one database until the code has moved, so I'm never migrating code and data in the same step.

I measure progress by the percentage of traffic served by the new app, legacy code deleted, and error rate and p95 per migrated route, with a flag to send a route back.

The trade-off: running two apps for a while costs effort, but every step is small and reversible.

🗣 Full answer (senior)

How I would answer this in an interview

"Big-bang rewrites of systems the business depends on have a terrible track record: the new system chases a moving target, and value arrives only at the end. So I'd use the strangler fig pattern. First I'd stand up a new ASP.NET Core 10 app that sits in front of everything, with YARP configured so any route it doesn't own is proxied to the existing MVC 5 app. On day one, users see no difference. Then we move one slice at a time: a set of routes, their views or API endpoints and their logic, into the new app, and flip the route in YARP behind a feature flag.

For example, at [company] we had a [400k-line] MVC 5 [claims portal]. I wrote an ADR for the strangler approach and ran a two-week spike to prove the hard parts: forms authentication shared through the System.Web adapters' remote authentication, session shared through remote session, and our shared business libraries retargeted to .NET Standard 2.0. We picked the first slice by value and coupling: the [document upload] area changed every sprint and had few dependencies. We kept one SQL Server database so only code moved. Over [18] months we moved [85%] of traffic to .NET 10 on Linux App Service, error rate per migrated route stayed [at or below] the legacy baseline, and hosting dropped by [40%] when we retired the Windows VMs. Feature work never stopped; about [30%] of capacity went to migration.

The mistake I see is starting with the most complex, central module, or trying to redesign the domain and the data model at the same time as the framework. My senior line is: make the migration boring: small slices, one kind of change at a time, and a rollback switch for every route."


Migration shape

            ┌────────────────────────────────────┐
 users ──►  │ ASP.NET Core 10 app (Linux)        │
            │  /documents/*  → handled here       │
            │  /claims/search → handled here      │
            │  everything else → YARP ──────┐      │
            └────────────────────────────────────┘
                                         ▼
                         ┌────────────────────────────┐
                         │ MVC 5 / .NET Framework 4.8  │
                         │ (Windows, IIS)              │
                         └────────────────────────────┘
                 both ──► one SQL Server database (for now)

Choosing slices

Criterion Prefer first Defer
Coupling Few dependencies, clear routes Central, shared by everything
Change frequency Changes every sprint (migration pays back fast) Stable, rarely touched
Risk Moderate, well understood Payment/settlement core
Tech blockers Plain MVC/Web API WCF server, WebForms, System.Web deep usage

Shared concerns during transition

Concern Approach
Authentication System.Web adapters remote authentication, or move both to OIDC with Entra ID
Session System.Web adapters remote session, then remove session dependence
Shared libraries Retarget to .NET Standard 2.0 or multi-target net48;net10.0
Data One database first; module ownership later
Config/secrets Key Vault for both apps

Production example

Over [18] months the strangler migration moved [85%] of traffic to .NET 10, kept migrated-route error rates at or below baseline, cut hosting by [40%] after retiring Windows VMs, and reduced deploy time from [45] to [8] minutes, without a feature freeze.

🔍 What the interviewer is checking

Checks whether the candidate can plan a realistic, incremental legacy migration that keeps delivering, handles shared state, and is measurable and reversible.

Green flags

  • Strangler fig with YARP and per-route rollback
  • Knows System.Web adapters for shared auth/session
  • Sequences changes (framework, then architecture, then data)
  • Measures traffic share, legacy deleted and quality per route

Red flags

  • Proposes a rewrite with a feature freeze
  • Splits into microservices as part of the framework migration
  • No plan for auth, session or shared libraries

📚 Learn in depth

1. Why strangler fig

Martin Fowler named it after vines that grow around a tree until they replace it. The key properties: the old system keeps running, value is delivered continuously, and every step can be reversed. It turns one huge risk into many small ones.

2. The YARP front door

YARP (Yet Another Reverse Proxy) is a Microsoft library that runs inside ASP.NET Core. In the new app, local endpoints are matched first; a catch-all route with low priority forwards everything else to the legacy app. Microsoft's incremental migration guidance uses exactly this setup.

Request ──► ASP.NET Core routing
              ├─ matches local endpoint? ──► handle in .NET 10
              └─ no ──► MapForwarder("/{**catch-all}", legacyUrl)  (lowest order)

Because YARP is just middleware, you can wrap a route's switch in a feature flag, send a percentage of traffic, and observe both sides in Application Insights.

3. System.Web adapters

Microsoft.AspNetCore.SystemWebAdapters provides:

  • API shims (HttpContext.Current-like surface) so shared code using System.Web types can compile against .NET 10.
  • Remote app authentication: the new app asks the legacy app to authenticate the request, so a forms-auth cookie works in both.
  • Remote app session: the new app reads/writes the legacy app's session over a secured channel.

These are transition tools; the end state removes session dependence and moves auth to OIDC (for example Microsoft Entra ID).

4. Code you can't move directly

Legacy tech Modern path
ASP.NET MVC 5 / Web API 2 ASP.NET Core MVC or Minimal APIs
WebForms Rewrite pages (Razor Pages, Blazor) slice by slice
WCF server CoreWCF, or gRPC/HTTP APIs
EF6 EF6 runs on .NET Core 3.1+; move to EF Core later
System.Web everywhere Adapters, then refactor
AppDomains, Remoting Processes, containers, HTTP/gRPC

The .NET Upgrade Assistant (and GitHub Copilot's app modernisation tooling, which Microsoft now promotes for this) automates project file conversion and package updates; it doesn't do the architectural work.

5. Data strategy

Changing framework, architecture and data model at once multiplies risk. Sequence:

  1. Both apps share the existing database (EF6 or EF Core on .NET 10 against the same schema).
  2. As slices move, give them module ownership of their tables (schema per module) in the new app.
  3. Only then consider splitting databases if a driver exists.

6. Measuring progress

  • Traffic share: requests served by the new app vs proxied (YARP metrics, Application Insights).
  • Routes/features migrated and legacy LOC deleted (deletion is the real finish line).
  • Quality per route: error rate and p95 compared with the legacy baseline.
  • Delivery: DORA metrics for the new app vs old.
  • Cost: hosting as Windows VMs retire.

Publish a burn-up chart; it keeps leadership support when the migration spans many quarters.

Try it yourself

  1. Create an ASP.NET Core 10 app with MapForwarder to an existing site and confirm unmatched routes pass through.
  2. Add one local endpoint and toggle it with Microsoft.FeatureManagement.
  3. Run the .NET Upgrade Assistant analysis on a .NET Framework project and review its report.
  4. Retarget a shared class library to netstandard2.0 and fix the compile errors.
  5. Build an Application Insights workbook showing requests per route split by app.

💻 Code

The new ASP.NET Core 10 front door: migrated routes are local; everything else goes to the legacy app through YARP.

// Program.cs (new ASP.NET Core 10 app)
using Microsoft.FeatureManagement;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddHttpForwarder();
builder.Services.AddFeatureManagement();
builder.Services.AddSystemWebAdapters()
    .AddRemoteAppClient(o =>
    {
        o.RemoteAppUrl = new Uri(builder.Configuration["Legacy:Url"]!);
        o.ApiKey = builder.Configuration["Legacy:ApiKey"]!; // from Key Vault, shared with the legacy app
    })
    .AddAuthenticationClient(isDefaultScheme: true)    // reuse the legacy forms-auth login
    .AddSessionClient();                               // read/write legacy session during transition

builder.Services.AddControllersWithViews();

var app = builder.Build();

app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseSystemWebAdapters();

// Migrated slice: documents. Behind a flag so a route can be sent back to legacy instantly.
app.MapControllers();
app.MapGet("/documents/{id:guid}", async (Guid id, IFeatureManager flags, HttpContext ctx, CancellationToken ct) =>
    await flags.IsEnabledAsync("Migrated.Documents", ct)
        ? Results.Ok(new { id, source = "net10" })
        : Results.StatusCode(StatusCodes.Status404NotFound));

// Everything not handled above goes to the .NET Framework app.
app.MapForwarder("/{**catch-all}", app.Configuration["Legacy:Url"]!)
   .WithOrder(int.MaxValue)
   .ShortCircuit();

app.Run();
<!-- Shared business library used by both apps during the transition -->
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net48;net10.0</TargetFrameworks>
    <Nullable>enable</Nullable>
    <LangVersion>latest</LangVersion>
  </PropertyGroup>
</Project>

In a real setup the flag would control which route table YARP uses rather than return 404; the snippet keeps the idea small.

⚠ Common mistakes

  • Mistake: Big-bang rewrite with a feature freeze. Why it is wrong: The target keeps moving, value arrives only at the end, and the cut-over is a huge risk. Instead: Strangler fig with route-by-route moves.
  • Mistake: Starting with the most central, complex module. Why it is wrong: You hit every hard problem at once and lose momentum and trust. Instead: Start with a valuable, loosely coupled slice to prove the approach.
  • Mistake: Changing framework, architecture and data model in one step. Why it is wrong: Failures are hard to attribute and roll back. Instead: One kind of change at a time; keep the database shared at first.
  • Mistake: Duplicating auth so users log in twice. Why it is wrong: Bad UX and security gaps. Instead: System.Web adapters remote auth, or move both apps to the same OIDC provider.
  • Mistake: Exposing the System.Web adapters remote-app endpoints carelessly. Why it is wrong: They can read session and authenticate users, so a leaked key or public endpoint is a serious hole. Instead: HTTPS only, a strong API key from Key Vault rotated regularly, network restrictions so only the new app can call them, and removal once migration ends.
  • Mistake: Switching to OIDC mid-migration without planning cookies and tokens. Why it is wrong: Different cookie names, domains or SameSite settings cause login loops, and storing tokens in the browser invites XSS theft. Instead: Plan a single sign-in cookie domain, keep tokens server-side (BFF pattern), and test logout across both apps.
  • Mistake: Not watching latency of proxied and remote-session calls. Why it is wrong: Every legacy route and session read now crosses an extra hop, and slowdowns get blamed on the new app. Instead: Trace end to end through YARP and compare per-route p95 with the baseline.
  • Mistake: Forking shared libraries into old and new copies. Why it is wrong: Bug fixes must be made twice and drift. Instead: Multi-target or retarget to .NET Standard 2.0.
  • Mistake: No rollback per route. Why it is wrong: A defect in a migrated slice becomes an outage. Instead: Feature-flag the routing and keep the legacy path until stable.
  • Mistake: Never finishing the last 20%. Why it is wrong: You pay to run two stacks forever. Instead: Plan and fund decommissioning, and set a date to turn the legacy app off.

🏛 Senior insight: trade-offs

The hardest part of a long migration is keeping organisational support. I make progress visible every month (traffic share, cost saved, deploy time) and tie slices to business features so migration work also ships value. I negotiate a steady capacity share (often 20-30%) rather than asking for a freeze.

I also decide explicitly what not to migrate: rarely used admin pages may be cheaper to retire or replace with a SaaS tool.

Option When it fits Cost When not to
Strangler fig with YARP Web app with route-addressable features Running two apps for a while Tiny app that can be rewritten in weeks
In-place upgrade (Upgrade Assistant) Class libraries, simple Web API, few System.Web dependencies Low-medium Heavy WebForms, WCF server, deep System.Web
Rewrite Small, well-understood system, or no longer fits the business High risk Large, business-critical, poorly documented
Retire/replace with SaaS Commodity capability Licence cost Core differentiating domain

🔗 Follow-ups the interviewer may ask

  1. When: Candidate talks about keeping feature delivery during the migration Why: Checks how they plan and fund large refactorings
    How to answer

    I treat a large refactoring as a series of small, behaviour-preserving steps merged to main continuously, not a big-bang branch. First I pin current behaviour with characterisation tests. Then I pick a technique: strangler fig to route traffic piece by piece to a new implementation, branch by abstraction to put an interface in front of the old code and swap implementations behind it, or parallel change (expand, migrate, contract) for APIs and database schemas. Feature flags and shadow comparisons let old and new paths run side by side. I prioritise hotspots (code that changes often and hurts), keep refactoring commits separate from feature commits, and define an end state so it does not drag on forever.

  2. When: Candidate mentions moving towards modules or services after the framework move Why: Checks their criteria for extracting services later
    How to answer

    I keep a modular monolith until a module has a measured reason to become its own deployable: it needs to scale independently, it has a different release cadence or owning team, it needs fault or security isolation, or it needs a different runtime. "Microservices are modern" isn't a reason.

    The first candidate should have few inbound dependencies, a clean contract and its own schema already. Extraction is incremental: make the module talk only through its contract, stop cross-module joins and transactions, move its data, deploy it as a service, and switch traffic behind a feature flag with a rollback path.

    The trade-off: every extracted module turns method calls into network calls, so you gain autonomy and isolation but pay with latency, partial failures and eventual consistency.

  3. When: Candidate mentions protecting the new model from the legacy one Why: Checks how an anti-corruption layer isolates the new code
    How to answer

    An anti-corruption layer is code on the downstream side that translates an upstream model into yours, so the upstream's names, codes and quirks never reach your domain. It has three parts. A port: an interface your domain defines in its own language (IIdentityVerifier). A facade/client: a typed HttpClient with AddStandardResilienceHandler() (timeouts, retries with jitter, circuit breaker). A translator: pure functions mapping both ways, vendor DTOs and codes to your value objects and your types to validated vendor requests. An adapter implements the port, lives in Infrastructure and is internal.

    Unknown codes map to a safe outcome and are logged and metered so upstream changes are caught the same day. Test translators with unit tests, the adapter against WireMock.Net, and run contract tests against the sandbox. The trade-off: extra code, in exchange for surviving or replacing the upstream without touching the domain.

🛠 Real-world problems: how you handle them

Strangling a 400k-line MVC 5 claims portal onto .NET 10
Situation
A [claims portal] on ASP.NET MVC 5 / .NET Framework 4.8, about [400k] lines, on Windows VMs, used by [3,000] staff and partners daily, with a team of [8] who also had a full feature roadmap.
Signals
45-minute deployments, Windows-only hosting at high cost, inability to use current libraries, recruitment difficulty, and [two] security findings about end-of-support dependencies.
Investigation
I ran the .NET Upgrade Assistant analysis, mapped routes against change frequency from git history and traffic from IIS logs, listed `System.Web` and WCF dependencies, and spiked YARP plus System.Web adapters for remote auth and session over [two] weeks.
Resolution
An ADR for the strangler approach; a new .NET 10 app on Linux App Service in front with YARP; shared libraries multi-targeted; one SQL Server database retained. Slices moved by value and coupling, each behind a feature flag, with [30%] of capacity on migration.
Prevention
A monthly burn-up of traffic share and legacy LOC deleted, per-route error and latency dashboards against the legacy baseline, an architecture test stopping new code from being added to the legacy app, and a planned decommissioning date.

How to tell it (STAR)

**S:** At [company] our [400k-line] MVC 5 claims portal ran on Windows VMs with 45-minute deploys, and the business couldn't pause features. **T:** As tech lead I had to modernise it to .NET 10 without a freeze. **A:** I wrote an ADR for a strangler fig migration and ran a two-week spike proving YARP and System.Web adapters for shared login and session. I chose the first slice by value and coupling, agreed a [30%] capacity share with the product owner, and published a monthly burn-up. **R:** In [18] months [85%] of traffic ran on .NET 10, deploys dropped from [45] to [8] minutes, hosting fell [40%], and feature delivery continued throughout.

↩ Usually asked after

More in Senior-Level Architecture

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me