Hands-on migration of a class library and an MVC 5 app to .NET 10: converting to SDK-style projects, multi-targeting net48 and net10.0, packages.config to PackageReference, Global.asax and web.config to Program.cs and appsettings.json, and where GitHub Copilot app modernisation helps.
I go bottom-up. First the class library: convert it to an SDK-style project, move packages.config to PackageReference, and multi-target net48;net10.0 so the existing MVC 5 app keeps consuming it while the new app is built. Differences go behind #if NET or conditional package references.
The MVC 5 app can't be retargeted in place, because System.Web doesn't exist on .NET 10. I create a new ASP.NET Core project, move controllers and views across, and translate Global.asax into Program.cs middleware and services, and web.config into appsettings.json with options. GitHub Copilot app modernisation automates much of the project editing; I still review every change. The trade-off: multi-targeting doubles build and test time for a while, but it keeps production shipping throughout.
"I split this into two different jobs, because they are. The class library is a retarget: I convert the old verbose
.csprojto SDK style, either by hand or withtry-convert, movepackages.configtoPackageReference, and set<TargetFrameworks>net48;net10.0</TargetFrameworks>. Most code compiles unchanged. Where it doesn't, say it readsConfigurationManager.AppSettings, I push that dependency out to the caller as an options object, or use#if NETas a short-term bridge. CI builds and tests both targets, so the existing MVC 5 app can keep consuming the library from the same commit.The MVC 5 app is not a retarget, it's a port. ASP.NET Core has no
System.Web, noGlobal.asax, noHttpModulepipeline. So I create a new ASP.NET Core project, bring controllers and Razor views across, which mostly survive with small changes, and rebuild the plumbing:Application_Startbecomes service registrations inProgram.cs,Application_BeginRequestand HTTP modules become middleware, filters move to the MVC options, andweb.configapp settings becomeappsettings.jsonbound to options classes. For a big app I'd do this route by route behind YARP rather than in one go.On tooling, GitHub Copilot app modernisation in Visual Studio now does the project conversion and proposes code fixes; the old Upgrade Assistant is deprecated. The mistake I see is trusting the tool's green build: model binding, JSON casing and filter order all change behaviour without a compile error. Tests on both runtimes are what make this safe."
| MVC 5 / .NET Framework | ASP.NET Core on .NET 10 |
|---|---|
Global.asax Application_Start |
Program.cs builder + app pipeline |
RouteConfig.RegisterRoutes |
app.MapControllerRoute / attribute routing |
FilterConfig / GlobalFilters |
AddControllersWithViews(o => o.Filters.Add(...)) |
BundleConfig (System.Web.Optimization) |
Static files + a front-end build, or MapStaticAssets() |
| HTTP modules / handlers | Middleware / endpoints |
web.config <appSettings>, <connectionStrings> |
appsettings.json, user secrets, Key Vault, IOptions<T> |
HttpContext.Current |
HttpContext in controllers, IHttpContextAccessor sparingly |
| Unity / Autofac container | Built-in DI (Autofac still works if needed) |
packages.config |
<PackageReference> |
ApiController (Web API 2) |
ControllerBase + [ApiController] |
| Task | Tool | You |
|---|---|---|
| SDK-style conversion, PackageReference | Automated | Review conditional items, remove dead references |
| Retarget, package upgrades | Automated with suggestions | Choose replacements, test behaviour |
| Create ASP.NET Core project, copy controllers/views | Partly automated | Rebuild pipeline, auth, config, DI |
System.Web call sites |
Suggestions | Design: adapters, DI or refactor |
| Behaviour parity | Not covered | Characterisation and integration tests |
For an internal claims app with 6 libraries and one MVC 5 site, the libraries were multi-targeted in two weeks with no production change. The web port went route by route over three months behind YARP; p95 latency on the migrated routes dropped from 410 ms to 160 ms, and memory per instance fell by about 40%.
Checks hands-on familiarity with the actual mechanics of migrating projects and the MVC pipeline, not just the strategy.
Green flags
Red flags
TargetFramework is enough for the web appOld .csproj files list every source file, every reference with a HintPath, and import MSBuild targets by path. SDK-style projects use globbing and implicit imports, so a 400-line file usually becomes 15 lines.
Old style SDK style
------------------------------ ------------------------------
<Project ToolsVersion="15.0"> <Project Sdk="Microsoft.NET.Sdk">
<Compile Include="A.cs" /> x 300 (globbed automatically)
packages.config + HintPath <PackageReference Include=... />
AssemblyInfo.cs Generated from properties
Web Application Projects (MVC 5) can't be fully SDK-style on .NET Framework without community SDKs, which is one more reason the web app is a new project rather than a conversion.
With <TargetFrameworks>net48;net10.0</TargetFrameworks>, MSBuild runs an inner build per target. Each defines symbols: NET48, NETFRAMEWORK, NET10_0, NET, NET5_0_OR_GREATER and so on. You can vary code (#if NETFRAMEWORK), package references (Condition="'$(TargetFramework)' == 'net48'") and compile items. NuGet packs both into one package under lib/net48 and lib/net10.0.
Domain.csproj
/ \
inner build net48 inner build net10.0
| |
bin/net48/Domain.dll bin/net10.0/Domain.dll
| |
MVC 5 app (net48) ASP.NET Core app (net10.0)
MVC 5 runs inside IIS's integrated pipeline via System.Web.HttpApplication. ASP.NET Core is a self-hosted pipeline (Kestrel, optionally behind IIS via the ASP.NET Core Module). The request object model, configuration system, DI and hosting all differ. Controllers and Razor views are the parts that carry across, with changes:
ActionResult types mostly survive; HttpStatusCodeResult becomes StatusCodeResult.[FromBody] is inferred for complex types under [ApiController].Html.Partial becomes <partial> or Html.PartialAsync.For anything non-trivial you put YARP in the new ASP.NET Core app, proxy everything to the old site, and move routes one at a time. System.Web adapters let shared code keep using System.Web.HttpContext-style APIs during the transition, and remote session/authentication share state with the old app.
Run the test project multi-targeted too (net48;net10.0) so the same tests prove both builds. For the web app, WebApplicationFactory<Program> integration tests should record responses from the old app (golden files) and compare.
dotnet tool install -g try-convert and try-convert -p Domain.csproj; diff the result.#if NETFRAMEWORK; inspect both DLLs with dotnet pack output.dotnet new mvc app and list every change you needed.JsonSerializerOptions.WebApplicationFactory test that asserts the ported route returns the same HTML fragment as the old one.Before and after: Global.asax plus web.config versus Program.cs plus appsettings.json.
// BEFORE: Global.asax.cs on .NET Framework 4.8 (MVC 5)
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
UnityConfig.RegisterComponents();
}
protected void Application_BeginRequest()
{
// Correlation id read from a header and stashed in HttpContext.Items
HttpContext.Current.Items["CorrelationId"] =
Request.Headers["X-Correlation-Id"] ?? Guid.NewGuid().ToString();
}
}
// AFTER: Program.cs on .NET 10
using Contoso.Claims.Web;
var builder = WebApplication.CreateBuilder(args);
// web.config <appSettings> -> appsettings.json section, validated at start-up
builder.Services.AddOptions<ClaimsOptions>()
.Bind(builder.Configuration.GetSection("Claims"))
.ValidateDataAnnotations()
.ValidateOnStart();
// FilterConfig -> MVC options; UnityConfig -> built-in DI
builder.Services.AddControllersWithViews(o => o.Filters.Add<AuditFilter>());
builder.Services.AddScoped<IClaimService, ClaimService>();
var app = builder.Build();
// Application_BeginRequest -> middleware
app.Use(async (context, next) =>
{
context.Items["CorrelationId"] =
context.Request.Headers["X-Correlation-Id"].FirstOrDefault() ?? Guid.NewGuid().ToString();
await next(context);
});
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
app.Run();
namespace Contoso.Claims.Web
{
public sealed record ClaimsOptions
{
[System.ComponentModel.DataAnnotations.Range(1, 365)]
public int MaxClaimAgeDays { get; init; } = 90;
}
}
// web.config <add key="MaxClaimAgeDays" value="90" /> becomes:
{
"Claims": { "MaxClaimAgeDays": 90 },
"ConnectionStrings": { "Claims": "set in user secrets or Key Vault, never here" }
}
The shared library, multi-targeted, with one bridging difference:
namespace Contoso.Claims.Domain;
public sealed class ClaimPolicy(int maxClaimAgeDays)
{
// Configuration is passed in, so the library no longer calls ConfigurationManager
public bool IsInTime(DateOnly lodged, DateOnly incident) =>
lodged.DayNumber - incident.DayNumber <= maxClaimAgeDays;
#if NETFRAMEWORK
// Bridge for the old app until it is retired
public static ClaimPolicy FromAppSettings() =>
new(int.Parse(System.Configuration.ConfigurationManager.AppSettings["MaxClaimAgeDays"] ?? "90"));
#endif
}
ConfigurationManager calls inside shared libraries. Why it is wrong: they silently return null on .NET 10 when no app.config exists. Instead: pass settings in through constructors or options.The real decision is where to put the seam. Libraries are cheap to multi-target and give you a shared core; the web layer is expensive and is where incremental migration pays off. You can't retarget System.Web, but you don't have to port it all at once either: YARP in the new app forwards unported routes to the old one, and System.Web adapters (Microsoft.AspNetCore.SystemWebAdapters) let shared libraries keep using HttpContext-style APIs and share session and authentication with the old app while you move. I keep multi-targeting temporary, with an exit date, because two runtimes in CI is a tax.
On tooling: GitHub Copilot app modernisation is Microsoft's current assistant (it needs a paid Copilot plan); the legacy .NET Upgrade Assistant can still be enabled in Visual Studio, and try-convert handles SDK-style conversion. All of them save typing, none of them prove behaviour. I measure p95 latency, memory and error rate per migrated route against the old app before switching traffic.
| Approach | When it fits | Cost | When not to |
|---|---|---|---|
Multi-target net48;net10.0 |
Library shared by old and new apps | Double builds/tests | Old app is retired within weeks |
Retarget to netstandard2.0 |
Pure logic, no newer APIs needed | Can't use modern APIs | Library needs Span, new BCL types |
| New ASP.NET Core app + YARP + adapters | Large MVC app, must keep shipping | Proxy layer, shared auth | Tiny app: port in one go |
| In-place port | Small app, good tests | One big release | Business-critical with weak tests |
An SDK-style project begins with <Project Sdk="Microsoft.NET.Sdk">. That one attribute pulls in all the standard build logic, so the file only holds what's specific to your project: the target framework, the output type, a few settings and its references. Source files are picked up automatically by globbing, so you don't list each .cs file. Packages are PackageReference items. Old-style .NET Framework project files listed every file, imported targets by hand and used packages.config. That made them long, noisy in merges and tied to Visual Studio on Windows.
Classic ASP.NET sits on System.Web.dll, which is bound to IIS and Windows. MVC 5 and Web API 2 were two separate frameworks: different controller base classes (Controller vs ApiController), filters, routing and DI hooks. App start-up lived in Global.asax, cross-cutting code in HttpModules, request data came from the ambient HttpContext.Current, and settings came from web.config.
ASP.NET Core replaces all of that: one MVC framework for pages and APIs, Program.cs for start-up, middleware for modules, HttpContext passed explicitly (or IHttpContextAccessor), appsettings.json plus environment variables via the options pattern, and built-in DI. The trade-off: it is faster and cross-platform, but nothing in System.Web compiles against it unchanged.
Multi-target in the .csproj (<TargetFrameworks>net48;net8.0;net10.0</TargetFrameworks>, or netstandard2.0;net10.0 if you need no Framework-only APIs), use #if NETFRAMEWORK sparingly, and let dotnet pack produce one lib/<tfm> folder per target. Run the test suite on every target in CI. Only target supported runtimes: .NET 6 and 7 are out of support, so the modern targets are the LTS releases (.NET 8 and .NET 10).
Decide when to drop net48 from data, and review it regularly (for example each major release): NuGet download stats per framework, internal consumers' target frameworks, and support requests. Announce the removal a release ahead, and remove it in a major version because dropping a target is a breaking change.
How to tell it (STAR)
**S:** We were migrating [a claims system] from MVC 5 to ASP.NET Core 10, with a shared library multi-targeted for both. **T:** Business users reported the two apps disagreeing on which claims were in time, and I owned the fix. **A:** I wrote a characterisation test, ran it on both targets and found the library reading `ConfigurationManager`, which silently returned null on .NET 10. I patched config in the new app the same day, then moved the setting to validated options passed into the library and banned `ConfigurationManager` in shared code with an analyser. **R:** Both apps agreed again within [a day], and the test suite now runs on both runtimes; we caught [three] similar issues before they reached production.
Last updated 23 Nov 2026.