.NET Framework to modern .NET
Move a .NET Framework 4.8 banking application to .NET 10: find the blockers with a scanner, choose between AWS Transform for .NET, Microsoft tooling and a strangler approach, fix WCF, Web Forms and Windows-only code, containerise on Linux, and decide honestly when staying on Windows is right.
Assumes: .NET Framework 4.8 → .NET 10 LTS · AWS Transform for .NET · Microsoft.Data.SqlClient · EF Core 10 · AWS CDK v2 (C#) · Terraform AWS provider v6 · Region us-east-1. Verified against official sources on 2026-11-18.
Learning objectives
By the end of this lesson you can:
- Decide, per application, between stay on Windows, port to .NET 10 on Linux, and strangle gradually, using blockers, cost and risk.
- Run a blocker scan over a .NET Framework codebase and turn the result into a prioritised porting backlog.
- Explain what AWS Transform for .NET and Microsoft's upgrade tooling do and what they leave to you.
- Fix the common blockers:
System.Web,web.config, Entity Framework 6,System.Data.SqlClient, WCF, Web Forms and Windows-only APIs. - Containerise the result for Linux (and know when a Windows container is the right fallback) and deploy it to ECS on Fargate with C# CDK or Terraform.
Prerequisites
- Porting .NET Framework apps to AWS — the module 3 lesson this one extends from a migration-programme angle
- Containerising .NET and Deploy to Fargate
- Migration assessment and portfolio discovery — the 7 R decision that brought you here
- Tools: .NET 10 SDK or Docker. No AWS account is needed.
Why this matters in banking
Harbourline's Branch Portal is a 2013 ASP.NET MVC 5 and Web Forms application on .NET Framework 4.8, with a WCF service that three other systems call, Windows authentication against Active Directory, Entity Framework 6 and a few System.Drawing calls that render cheque images. It works, it is audited, and it runs on four Windows Server VMs with licences that cost more than the compute.
Rehosting would move it in a month. Porting it to .NET 10 on Linux removes the Windows licence line and opens containers, but it touches a payments-adjacent code path and needs regression evidence. Leaving it for "later" has a price too: the Framework 4.8 component itself continues to be supported with Windows, but the ecosystem (new libraries, security tooling, AWS SDK generations) moves on to modern .NET. Each year of delay makes the port larger. The decision should be made deliberately, with data.
The idea in plain language
".NET Framework" and ".NET" (the modern one, currently .NET 10 LTS) are two different runtimes. Framework is Windows-only and in maintenance. Modern .NET is cross-platform and where all new work happens. Porting is mostly replacing the pieces that only exist on Framework with modern equivalents, then recompiling:
| Layer | Framework | Modern .NET |
|---|---|---|
| Web stack | System.Web (ASP.NET MVC 5, Web API 2, Web Forms) | ASP.NET Core |
| Service contracts | WCF (server) | CoreWCF, gRPC or REST |
| Data access | Entity Framework 6, System.Data.SqlClient | EF Core, Microsoft.Data.SqlClient |
| Config | web.config, ConfigurationManager | appsettings.json, options pattern, Secrets Manager |
| Identity | Windows auth, Forms auth | OIDC, JWT, Cognito or Identity Center |
| Hosting | IIS | Kestrel in a container |
Tools do the mechanical part (project files, namespaces, package versions, many API swaps). A person does the architectural part (sessions, authentication, WCF contracts, transactions) and, crucially, proves behavioural equivalence.
Analogy: Converting a petrol delivery van to electric. A conversion kit swaps the engine mount and wiring (mechanical, automatable), but someone still has to recalibrate the brakes and re-test the vehicle before it goes back on the road (behavioural, human).
What problem the AWS tooling solves
| Tool | What it does | Status and limits (checked 2026-11-18) |
|---|---|---|
| AWS Transform for .NET | An AI-assisted service that analyses .NET Framework solutions and transforms code to cross-platform .NET; works through AWS Transform's web application or Visual Studio integration; produces a transformed branch and a report for review | GA since May 2025. Supported project types, target versions and pricing change; confirm the .NET 10 target and current costs ⚠ VERIFY. Output must be reviewed and tested |
| Porting Assistant for .NET, App2Container, Microservice Extractor, Toolkit for .NET Refactoring | Older AWS .NET modernisation tools | Closed to new customers on 2025-11-07. Do not start new work on them |
| .NET Upgrade Assistant (Microsoft) | CLI and Visual Studio tool that upgrades project files and packages | Microsoft has been steering users toward a Copilot-based modernisation agent; the older tool is no longer developed ⚠ VERIFY current status |
| Microsoft System.Web adapters | Library that lets you migrate incrementally, sharing session and authentication between an old and a new app | Useful for strangler migrations ⚠ VERIFY the supported scenarios and versions |
| CoreWCF | Open-source WCF server for ASP.NET Core | Supports common bindings; check yours ⚠ VERIFY |
None of these tools can tell you whether the ported application behaves the same. That is your test suite and your reconciliation evidence.
Microsoft / Azure comparison
| You know (Microsoft/Azure) | AWS equivalent | What's different |
|---|---|---|
| IIS or Azure App Service (Windows) | ECS Fargate (Linux container), Elastic Beanstalk (Windows or Linux), ECS Express Mode | Linux is cheaper (no Windows licence). Beanstalk keeps IIS if you must |
| App Service "Always On", slots | ECS rolling or blue/green deploys, ALB health checks | Slot swaps become weighted target groups |
| Azure App Service Windows authentication | None built in; use OIDC (Entra ID via Identity Center or Cognito federation) | Kerberos in containers is possible but heavy; redesign if you can |
| Azure Migrate app-modernisation assessments | AWS Transform for .NET assessment | Both produce a compatibility report |
| Azure Functions in-process on Framework | Lambda with the dotnet10 managed runtime | Cold-start and packaging differ (Lambda with C#) |
| Azure Container Apps | ECS Express Mode or Fargate | Express Mode is the simple path; App Runner is closed to new customers |
| Azure Key Vault config | Secrets Manager and Parameter Store | See Configuration done right |
Architecture
Security-boundary view. The ALB terminates TLS and applies WAF rules; both applications run in private subnets and accept traffic only from the ALB security group. In the strangler phase, shared session and authentication are the dangerous seam: two apps trusting one cookie or one cache means a cookie-handling flaw in either exposes both. Use signed, short-lived tokens, and keep the cache in a private subnet with encryption in transit and at rest.
Step-by-step implementation
Triage: stay, port or strangle
Run the blocker scanner (below) on every candidate. Apply this rule of thumb:
| Signal | Leans toward |
|---|---|
| Few System.Web, no Web Forms, WCF optional, good tests | Port to .NET 10 |
| Large Web Forms estate, heavy third-party Windows controls, no tests | Stay on Windows (rehost) and plan a strangler or rewrite |
| Large, valuable, partly modular, can route by URL | Strangle with a proxy and the System.Web adapters |
| Vendor-supported package that only runs on Windows | Stay until the vendor ships a modern version |
Build a safety net first
Before touching code, add characterisation tests: API-level tests that record current behaviour for key flows (login, balance, payment initiation, statement). Also capture outputs of batch jobs for a fixed input set. These tests run against both the old and new builds.
Convert mechanically
Move to SDK-style project files, update packages, change TargetFramework to net10.0. Use AWS Transform for .NET where you have access (review the diff like a pull request from a junior developer), or the Microsoft tooling and your IDE.
Replace the blockers
Work the scanner's backlog by severity: configuration and data access first (because everything depends on them), then the web layer, then the Windows-only code. Examples below.
Prove equivalence
Run the characterisation tests against both versions, compare outputs, and run the data-layer checks (money is decimal in both, rounding mode is the same, time zones and culture settings are explicit). Performance test, because the runtime behaves differently.
Containerise and deploy
Build a Linux image, deploy to a non-production ECS service, run side by side with the old one, then shift traffic gradually (weighted target groups). Keep the old stack until the rollback window ends.
AWS Console instructions
- AWS Transform: sign in to the AWS Transform web application with IAM Identity Center, create a job for .NET modernisation, connect your repository (the supported sources are listed in the user guide ⚠ VERIFY), and review the generated branch and assessment report.
- ECR → Create repository (scan on push on, tag immutability on) for the image.
- ECS → Task definitions → Create (Fargate, Linux/X86_64 or Linux/ARM64), then Clusters → Services → Create behind an ALB. For a simple start choose ECS Express Mode ⚠ VERIFY the console flow, which AWS has been changing.
AWS CLI
# Create an immutable, scanning repository for the ported application.
aws ecr create-repository --repository-name hl/branch-portal \
--image-tag-mutability IMMUTABLE \
--image-scanning-configuration scanOnPush=true \
--profile learn-sandbox --region us-east-1
# Authenticate Docker to ECR (token valid for 12 hours).
aws ecr get-login-password --profile learn-sandbox --region us-east-1 \
| docker login --username AWS --password-stdin 123456789012.dkr.ecr.us-east-1.amazonaws.com
# Build for Linux and push.
docker build -t 123456789012.dkr.ecr.us-east-1.amazonaws.com/hl/branch-portal:1.0.0 .
docker push 123456789012.dkr.ecr.us-east-1.amazonaws.com/hl/branch-portal:1.0.0Replace 123456789012 with your account ID.
Infrastructure as Code
The same task definition runs on Linux Fargate for the ported application, and the lesson shows how a Windows fallback differs (only the runtime platform changes, but the cost and image size do).
using Amazon.CDK;
using Amazon.CDK.AWS.EC2;
using Amazon.CDK.AWS.ECR;
using Amazon.CDK.AWS.ECS;
using Amazon.CDK.AWS.ECS.Patterns;
using Amazon.CDK.AWS.Logs;
using Constructs;
namespace Harbourline.Migration.Infra;
public sealed class PortalServiceStack : Stack
{
public PortalServiceStack(Construct scope, string id, IStackProps? props = null)
: base(scope, id, props)
{
var vpc = new Vpc(this, "Vpc", new VpcProps { MaxAzs = 2, NatGateways = 1 });
var cluster = new Cluster(this, "Cluster", new ClusterProps { Vpc = vpc, ContainerInsightsV2 = ContainerInsights.ENABLED });
var repo = Repository.FromRepositoryName(this, "Repo", "hl/branch-portal");
var service = new ApplicationLoadBalancedFargateService(this, "Portal", new ApplicationLoadBalancedFargateServiceProps
{
Cluster = cluster,
Cpu = 512,
MemoryLimitMiB = 1024,
DesiredCount = 2,
// Linux, ARM64 is the cheapest option if your dependencies support it. Use X86_64 otherwise.
RuntimePlatform = new RuntimePlatform
{
OperatingSystemFamily = OperatingSystemFamily.LINUX,
CpuArchitecture = CpuArchitecture.ARM64
},
TaskImageOptions = new ApplicationLoadBalancedTaskImageOptions
{
Image = ContainerImage.FromEcrRepository(repo, "1.0.0"),
ContainerPort = 8080,
LogDriver = LogDrivers.AwsLogs(new AwsLogDriverProps
{
StreamPrefix = "portal",
LogRetention = RetentionDays.ONE_MONTH
}),
Environment = new Dictionary<string, string>
{
["ASPNETCORE_URLS"] = "http://+:8080"
}
},
PublicLoadBalancer = true // ⚠ learning shortcut: use an internal ALB behind CloudFront or WAF in production
});
service.TargetGroup.ConfigureHealthCheck(new Amazon.CDK.AWS.ElasticLoadBalancingV2.HealthCheck
{
Path = "/healthz"
});
// A Windows fallback changes only the platform and image: OperatingSystemFamily.WINDOWS_SERVER_2022_CORE
// with CpuArchitecture.X86_64 and a Windows base image ⚠ VERIFY current Windows-on-Fargate support and sizes.
Amazon.CDK.Tags.Of(this).Add("Project", "cea-lab");
Amazon.CDK.Tags.Of(this).Add("Lab", "m13-port");
Amazon.CDK.Tags.Of(this).Add("Environment", "learn");
Amazon.CDK.Tags.Of(this).Add("Owner", "your-name");
}
}Complete code
The blocker scanner
A console tool that scans a .NET Framework solution folder and prints a ranked porting backlog. It uses only the base class library.
using System.Text.RegularExpressions;
if (args.Length != 1 || !Directory.Exists(args[0]))
{
Console.Error.WriteLine("usage: dotnet run -- <path-to-solution-folder>");
return 1;
}
var root = Path.GetFullPath(args[0]);
var skipDirs = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "bin", "obj", "packages", "node_modules", ".git", ".vs" };
var results = new Dictionary<string, List<string>>();
foreach (var file in Walk(root, skipDirs))
{
var ext = Path.GetExtension(file).ToLowerInvariant();
if (ext is not (".cs" or ".csproj" or ".config" or ".aspx" or ".ascx" or ".svc" or ".asmx" or ".cshtml" or ".master")) continue;
string text;
try { text = File.ReadAllText(file); }
catch (IOException) { continue; } // locked file: skip, do not crash the scan
catch (UnauthorizedAccessException) { continue; }
foreach (var rule in Rules.All)
{
if (rule.Extensions.Length > 0 && !rule.Extensions.Contains(ext)) continue;
var count = rule.Pattern.Matches(text).Count;
if (count == 0) continue;
if (!results.TryGetValue(rule.Name, out var list)) results[rule.Name] = list = [];
list.Add($"{Path.GetRelativePath(root, file)} ({count})");
}
}
Console.WriteLine($"Scanned: {root}\n");
foreach (var rule in Rules.All.OrderBy(r => r.Severity).ThenBy(r => r.Name, StringComparer.Ordinal))
{
if (!results.TryGetValue(rule.Name, out var hits)) continue;
Console.WriteLine($"[{rule.Severity}] {rule.Name}: {hits.Count} file(s)");
Console.WriteLine($" fix: {rule.Fix}");
foreach (var h in hits.Take(5)) Console.WriteLine($" - {h}");
if (hits.Count > 5) Console.WriteLine($" ... and {hits.Count - 5} more");
}
var blockers = results.Keys.Count(k => Rules.All.First(r => r.Name == k).Severity == Severity.Blocker);
Console.WriteLine($"\nBlocker categories found: {blockers}");
return blockers == 0 ? 0 : 3;
static IEnumerable<string> Walk(string dir, HashSet<string> skip)
{
foreach (var f in Directory.EnumerateFiles(dir)) yield return f;
foreach (var d in Directory.EnumerateDirectories(dir))
{
if (skip.Contains(Path.GetFileName(d))) continue;
foreach (var f in Walk(d, skip)) yield return f;
}
}
enum Severity { Blocker = 0, Major = 1, Minor = 2 }
sealed record Rule(string Name, Severity Severity, Regex Pattern, string[] Extensions, string Fix);
static class Rules
{
private static Regex R(string p) => new(p, RegexOptions.Compiled | RegexOptions.CultureInvariant);
public static readonly Rule[] All =
[
new("System.Web (MVC 5, Web API 2, Web Forms)", Severity.Blocker,
R(@"using\s+System\.Web\b|System\.Web\.Mvc|HttpContext\.Current"), [".cs", ".cshtml"],
"Port to ASP.NET Core; inject IHttpContextAccessor instead of HttpContext.Current"),
new("Web Forms pages and controls", Severity.Blocker,
R(@"<%@\s*Page|runat\s*=\s*""server"""), [".aspx", ".ascx", ".master"],
"No direct port: rewrite as Razor Pages or an SPA, or keep on Windows"),
new("WCF service host", Severity.Blocker,
R(@"\[ServiceContract\]|ServiceHost\b|<system\.serviceModel"), [".cs", ".config", ".svc"],
"CoreWCF to keep the contract, or gRPC/REST to redesign"),
new("ConfigurationManager / web.config", Severity.Major,
R(@"ConfigurationManager\.(AppSettings|ConnectionStrings)"), [".cs"],
"IConfiguration and the options pattern; secrets to Secrets Manager"),
new("Entity Framework 6", Severity.Major,
R(@"using\s+System\.Data\.Entity|DbContext\s*:\s*DbContext|EntityFramework"), [".cs", ".csproj", ".config"],
"EF Core 10; review lazy loading, migrations and raw SQL"),
new("System.Data.SqlClient", Severity.Major,
R(@"System\.Data\.SqlClient"), [".cs", ".csproj", ".config"],
"Microsoft.Data.SqlClient (check Encrypt defaults: they are stricter)"),
new("Windows authentication / identity", Severity.Major,
R(@"WindowsIdentity|User\.Identity\.Name|windowsAuthentication"), [".cs", ".config"],
"OIDC/JWT; plan a Kerberos strategy only if unavoidable"),
new("Windows-only APIs (registry, event log, System.Drawing)", Severity.Major,
R(@"Microsoft\.Win32\.Registry|EventLog\b|System\.Drawing\b|System\.Management\b"), [".cs"],
"Cross-platform libraries (SkiaSharp, ImageSharp), CloudWatch Logs, configuration"),
new("Removed or unsafe APIs", Severity.Major,
R(@"BinaryFormatter|AppDomain\.CreateDomain|Thread\.Abort|System\.Messaging"), [".cs"],
"System.Text.Json, separate processes, CancellationToken, SQS instead of MSMQ"),
new("Session state and machine keys", Severity.Minor,
R(@"Session\[|<machineKey|<sessionState"), [".cs", ".config", ".cshtml"],
"Distributed cache (ElastiCache) or stateless tokens; protect data-protection keys"),
new("Old-style project (no SDK attribute)", Severity.Minor,
R(@"<Project\s+ToolsVersion"), [".csproj"],
"SDK-style project file; mechanical, tools do it")
];
}The Dockerfile for the ported result
# Build stage: full SDK, restores and publishes.
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY . .
RUN dotnet publish Harbourline.BranchPortal/Harbourline.BranchPortal.csproj \
-c Release -o /app/publish /p:UseAppHost=false
# Runtime stage: small image, non-root user.
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
WORKDIR /app
COPY --from=build /app/publish .
ENV ASPNETCORE_URLS=http://+:8080
EXPOSE 8080
USER $APP_UID
ENTRYPOINT ["dotnet", "Harbourline.BranchPortal.dll"]Two common replacements
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Options;
namespace Harbourline.BranchPortal;
public sealed class LedgerOptions
{
public const string Section = "Ledger";
public string ConnectionString { get; set; } = "";
}
public sealed class AccountRepository(IOptions<LedgerOptions> options)
{
private readonly string _connectionString = options.Value.ConnectionString;
public async Task<decimal?> GetBalanceAsync(string accountId, CancellationToken ct)
{
await using var conn = new SqlConnection(_connectionString);
await conn.OpenAsync(ct);
await using var cmd = new SqlCommand(
"SELECT balance FROM dbo.accounts WHERE account_id = @id", conn);
cmd.Parameters.Add("@id", System.Data.SqlDbType.VarChar, 14).Value = accountId;
var result = await cmd.ExecuteScalarAsync(ct);
return result is decimal d ? d : null; // money stays decimal, never double
}
}using Harbourline.BranchPortal;
var builder = WebApplication.CreateBuilder(args);
// web.config appSettings replaced by layered configuration: appsettings.json, environment, then Secrets Manager.
builder.Services.Configure<LedgerOptions>(builder.Configuration.GetSection(LedgerOptions.Section));
builder.Services.AddScoped<AccountRepository>();
builder.Services.AddHealthChecks();
var app = builder.Build();
app.MapHealthChecks("/healthz");
app.MapGet("/accounts/{id}/balance", async (string id, AccountRepository repo, CancellationToken ct) =>
await repo.GetBalanceAsync(id, ct) is { } balance
? Results.Ok(new { accountId = id, balance })
: Results.NotFound());
app.Run();Code explained line by line
- The scanner's
Rulesarray is the porting policy as data. Adding a rule is one line, and severity drives the report order, so the report reads as a backlog. RegexOptions.CompiledandCultureInvariantkeep the scan fast and independent of the machine's locale.- The catch blocks for
IOExceptionandUnauthorizedAccessExceptionskip locked files, so one open file does not abort a scan of a large solution. - The exit code is non-zero when blocker categories are found, so a pipeline can mark a candidate "needs design" automatically.
- In the Dockerfile, the two stages keep compilers out of the runtime image.
USER $APP_UIDuses the non-root user that the .NET 10 images define ⚠ VERIFY the variable name for your image tag.UseAppHost=falseavoids an unnecessary native launcher. AccountRepositoryuses a primary constructor to receive options, not staticConfigurationManager. The parameter is typed with a length (VarChar, 14), so SQL Server can reuse query plans, and the balance is read asdecimal.- The minimal API replaces a Web API 2 controller:
Results.OkandResults.NotFoundmap to the status codes the old controller returned, which the characterisation tests should assert.
Security considerations
⚠ Learning shortcut — not for production
The ALB above is public and the lesson container reads a connection string from configuration. In production keep the service behind an internal ALB fronted by CloudFront and WAF, read the connection string from Secrets Manager at start-up (or use IAM database authentication where the engine supports it), and run containers with a read-only root filesystem and no extra Linux capabilities.
- Stricter TLS defaults.
Microsoft.Data.SqlClientencrypts connections by default and validates the server certificate. A port that "works on the dev box" may fail against a SQL Server with a self-signed certificate. Fix the certificate; do not setTrustServerCertificate=truein production. - Authentication rewrites are security work. Replacing Windows authentication with OIDC changes who can log in and how sessions end. Treat it as a security change with its own review, and plan with the guidance in Federation and segregation of duties.
- Package supply chain. The port will add dozens of NuGet packages. Pin versions, scan in CI (Pipeline security scanning) and use ECR scan-on-push.
- Regression evidence. For a payments-adjacent system, a change board needs proof of equal behaviour: the characterisation test output is the proof.
Banking use case
Harbourline's portfolio has three Framework applications. The Branch Portal (Web Forms heavy) is strangled: a YARP-style proxy routes new pages to ASP.NET Core on Fargate while the System.Web adapters share session during the transition. The Statement Service (WCF plus Windows services) is ported using AWS Transform for .NET and CoreWCF to keep its three consumers working, then rebuilt as REST when those consumers migrate. The cheque-imaging tool, which depends on a licensed Windows imaging component, stays on Windows on a Beanstalk Windows environment, with a note on the risk register and a review date. All three decisions are recorded with the scanner output as evidence.
Common mistakes
- Porting before testing. Without characterisation tests you cannot show equivalence. Write tests first.
- Trusting tool output. Transform tools produce compiling code, not correct code. Review diffs, run tests, and check money and time handling.
- Ignoring culture and time zones. Linux containers default to different culture and time-zone data. Set
InvariantGlobalizationdeliberately and use UTC and explicit time zones. - Leaving file paths and case sensitivity alone. Linux file systems are case-sensitive and use
/. A Windows-path assumption becomes a runtime failure. - Lifting EF6 lazy-loading assumptions. EF Core does not lazy-load unless configured; N+1 behaviour and tracking differ.
- Forgetting the batch jobs. The web app ports; the scheduled tasks and Windows services are forgotten. Scan for them explicitly.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Login failed or certificate error after moving to Microsoft.Data.SqlClient | Default encryption now on, certificate untrusted | Install a trusted certificate or add the CA to the container trust store |
| Container exits immediately | App binds to localhost or wrong port | Set ASPNETCORE_URLS=http://+:8080 and match the target-group port |
| Fonts or images render differently | System.Drawing has no Linux backend in modern .NET | Use SkiaSharp or ImageSharp and install required fonts in the image |
| ALB health check fails | /healthz not mapped or needs auth | Map the health endpoint without authentication |
| A date or sort differs from the old system | Culture or time-zone difference | Set culture explicitly; use TimeProvider and UTC |
| Scanner reports nothing | Wrong root path or files with unusual extensions | Point at the solution folder; extend the extension list |
Cost and cleanup
Cost: free. The scanner and the container build run locally. Deploying the IaC to Fargate is a small paid exercise: 2 tasks at 0.5 vCPU and 1 GB, an ALB and a NAT gateway cost roughly USD 3 to 4 per day, with the NAT gateway and ALB the largest parts ⚠ VERIFY current prices. Deploy-and-destroy within an hour for under USD 1, or treat the IaC as a design-only exercise.
# CDK or Terraform users: destroy the stack.
cdk destroy
# terraform destroy
# Delete the ECR repository and its images.
aws ecr delete-repository --repository-name hl/branch-portal --force --profile learn-sandbox --region us-east-1
# Confirm nothing tagged Project=cea-lab remains.
aws resourcegroupstaggingapi get-resources --tag-filters Key=Project,Values=cea-lab --profile learn-sandboxExercises
- 🟢 Guided: Create a folder with two small
.csfiles, one usingHttpContext.CurrentandConfigurationManager.AppSettings, one clean. Run the scanner and confirm it ranks System.Web as a blocker. - 🟡 Challenge: Add a rule for
Thread.Sleepin request handlers and one forstaticmutable fields that hold per-user state. Explain why the second one matters more in a container than on a single IIS server. - 🔴 Live problem: A vendor ships a Windows-only imaging component that the cheque tool needs, and the vendor says a Linux version is "on the roadmap". Management wants the Windows licences gone this year. Write the options paper: keep a small Windows island, containerise on Windows, replace the vendor, or wrap the component behind a service. Include the cost and risk of each.
Assignment
Add a legacy-port-plan.md to your portfolio: scanner output for a sample .NET Framework app (use the open-source bobs-used-bookstore-classic sample from AWS samples, licence MIT-0), a stay/port/strangle decision per component, the characterisation tests you would write first, and a rollback approach.
Solutions
The scanner prints [Blocker] System.Web ... with the file listed and the count, and [Major] ConfigurationManager / web.config .... The clean file does not appear. The exit code is 3 because a blocker category was found.
Why: the exit code makes the tool usable as a gate in a pipeline: a candidate with unresolved blockers fails automatically, which prompts a design conversation rather than a mechanical upgrade.
Add two Rule entries, for example R(@"Thread\.Sleep\(") restricted to .cs as Minor and R(@"static\s+(?!readonly)\w[\w<>,\s]*\s+\w+\s*(=|;)") as Major, and accept some false positives (it is a heuristic).
Why: per-user state in static fields works by accident on one IIS server with sticky sessions. With several containers behind a load balancer, each instance has its own copy, so users see inconsistent data and one user's state can leak to another. That is a correctness and a privacy issue.
Knowledge check
Answer: Web Forms has no equivalent in ASP.NET Core (page lifecycle, view state, server controls). It must be rewritten (Razor Pages, an SPA) or left on Windows. The other System.Web parts have direct replacements.
Answer: Incremental delivery with a working system at every step, a small blast radius per change, and an easy rollback by routing back. The cost is running two stacks and sharing session and authentication across them.
Answer: Porting Assistant for .NET and the related older modernisation tools (App2Container, Microservice Extractor, Toolkit for .NET Refactoring), all closed to new customers on 2025-11-07.
Answer: When a vendor component only runs on Windows, when the application is large Web Forms with no appetite to rewrite, or when risk and deadline outweigh the licence saving. Record it as a deliberate Retain or Rehost with a review date.
Interview questions
- How do you prove a ported application behaves the same? Characterisation tests run against old and new, recorded batch outputs for fixed inputs, reconciliation of money values, and a parallel run with production-like data.
- What goes wrong most often in a .NET Framework port? Configuration and identity (Windows auth,
web.config), data-access defaults (EF6, SqlClient encryption), and Windows-only dependencies hidden in batch jobs. - Would you choose Windows containers? Only as a stop-gap for components that cannot move; they are larger, slower to start and carry a Windows licence cost.
Certification practice
A bank has a .NET Framework 4.8 ASP.NET MVC application with a few System.Web references and good unit tests. It wants to eliminate Windows licences and run on containers, with minimal risk. Which is the best approach?
A. Rehost to EC2 Windows with MGN and stop there. B. Use AWS Transform for .NET (or Microsoft tooling) to port to modern .NET, add characterisation tests, containerise on Linux and deploy to ECS Fargate with a gradual traffic shift. C. Rewrite the entire application in another language. D. Use Amazon Q Developer to convert the application and deploy directly to production.
Answer: B. The application is a good port candidate, and the plan includes tests and a staged rollout. A keeps the licences, C is a rewrite with the highest risk, and D skips testing (and Amazon Q Developer is no longer accepting new sign-ups).
Which change gives the largest recurring saving when moving a web tier from Windows Server on EC2 to AWS?
A. Move to a larger Windows instance. B. Port to modern .NET and run on Linux containers (for example Fargate on ARM64), removing the Windows licence component. C. Add a second NAT gateway. D. Turn on detailed monitoring.
Answer: B. The Windows licence is roughly half of a Windows instance's price (see the licensing lesson), and Linux and Graviton-based tasks are cheaper. A raises cost, C and D add cost.
Completion checklist
- I can explain the difference between .NET Framework and modern .NET in terms of hosting and libraries
- I ran the scanner on a sample and prioritised its output
- I can justify a stay, port or strangle decision with evidence
- I ran the cleanup steps and confirmed nothing is still billing
Key takeaways
- A port replaces Framework-only pieces; the tools do the mechanical part and you prove equivalence.
- Scan first, decide second: blockers drive the choice between stay, port and strangle.
- Write characterisation tests before changing code.
- Windows authentication and Web Forms are design problems, not search-and-replace problems.
- Staying on Windows is legitimate when recorded as a deliberate decision.
Further reading
- AWS Transform user guide — official entry point; check the .NET modernisation section
- Module 3: Porting .NET Framework apps — companion lesson with more before-and-after code
- Next: SQL Server database migration
Independent learning resource — not affiliated with, endorsed or sponsored by Amazon Web Services. AWS and related marks are trademarks of Amazon.com, Inc. or its affiliates. All banking data in examples is fictional. Sample architectures are for learning and are not automatically compliant with GDPR, PCI DSS or any banking regulation.
Rehosting with AWS Application Migration Service
Rehost Windows and Linux servers to Amazon EC2 with AWS Application Migration Service (MGN): set up the staging area, install the replication agent, run test launches, perform and finalise a cut-over, use post-launch actions, and keep a fast rollback.
SQL Server database migration
Run the data half of a Microsoft migration: choose the target (RDS for SQL Server, Aurora PostgreSQL with Babelfish, or a full conversion), triage T-SQL compatibility, replicate with AWS DMS full load plus change data capture, adapt EF Core, and prove the data matches with an independent reconciliation.