Covers Web Forms migration: why there is no automated path (ViewState, server controls, page lifecycle, code-behind business logic), comparing Razor Pages, Blazor (Server/WebAssembly/Auto) and an SPA, extracting logic first, page-by-page migration behind YARP with shared auth and session, and how to choose.
Web Forms has no automated migration path: server controls, ViewState, postbacks and the page lifecycle don't exist in ASP.NET Core, and business logic usually lives in code-behind. So the plan is: extract the logic first into tested services both UIs can use, then migrate page by page behind YARP, sharing authentication and session, while the Web Forms app keeps serving every page not yet moved.
For the target: Blazor is the closest mental model and suits internal line-of-business apps; Razor Pages is the simplest for form-and-page apps; an SPA fits when a separate front-end team justifies a new API layer. Users should barely notice the move except that pages get faster (losing ViewState often halves load times), so pilot pages with key users and test each one end to end. The trade-off: Blazor feels familiar but ties the UI to .NET; an SPA is more flexible but roughly doubles what you build and test.
"First I'd be honest about why Web Forms is the hardest legacy migration. There's no tool that converts it, because its core ideas don't exist in ASP.NET Core: server controls that render their own HTML, ViewState carrying control state in a hidden field, postbacks that replay the page lifecycle, and
UpdatePanelpartial refreshes. The bigger problem is usually that the business rules live inButton1_Clickhandlers in code-behind. So the first step isn't choosing a framework, it's pulling business logic out of code-behind into services with tests, which both the old pages and the new UI can call.For the target, I'd choose per app. Blazor is the closest mental model: components, event handlers and state that lives on the server, so Web Forms developers pick it up quickly; for an internal app, Blazor with interactive server rendering is a strong fit. Razor Pages is the simplest when pages are mostly forms and lists: one page, one handler, plain HTML. An SPA in React or Angular makes sense when there's a dedicated front-end team or very rich client behaviour, but it means designing and securing an API too. For example, at [company] we [moved an internal Web Forms app of about N pages to Blazor, page by page, over M months]; [result].
The migration itself runs page by page. A new ASP.NET Core app sits in front with YARP; any URL not yet migrated is forwarded to the Web Forms app. Authentication is shared with System.Web adapters or a shared cookie, and session either goes remote or moves to a distributed store. The mistake I see is a two-year rewrite that the business cancels at month fourteen. Shipping a migrated page every sprint keeps the funding."
| Web Forms concept | Why it doesn't carry over | What replaces it |
|---|---|---|
Server controls (GridView, asp:TextBox) |
Render their own HTML and state | Razor markup, Blazor components, tag helpers |
| ViewState | Hidden field with serialised control state | Explicit model binding, component state |
| Postback + page lifecycle | Page_Load, Page_PreRender, event replay |
Request handlers / component lifecycle |
UpdatePanel |
Partial postbacks via ASP.NET AJAX | Blazor interactivity, htmx, SPA calls |
| Code-behind business logic | Tied to the page class | Application services, MediatR handlers |
| Third-party control suites | Web Forms-only versions | Vendor's Blazor or JS suite (new licence) |
| Target | Fits | Costs | Avoid when |
|---|---|---|---|
| Blazor (Server / Auto) | Internal LOB apps, .NET team, many interactive forms | Server: a SignalR circuit per user; WebAssembly: download size | Public high-traffic sites with SEO needs (use static SSR) |
| Razor Pages | Form-and-page CRUD, SEO, simple hosting | Less interactivity without JS | Highly interactive dashboards |
| SPA + API | Separate front-end team, rich client, mobile reuse | Two codebases, API security, more tests | Small team of .NET developers only |
An internal case-management system had 140 Web Forms pages. Extracting logic took two months; then 8–12 pages a sprint moved to Blazor behind YARP. After nine months the Web Forms app served under 2% of requests and was retired the next quarter; page load time on migrated screens dropped from 2.8 s to 0.9 s, largely because ViewState (up to 400 KB on some pages) went away.
Checks that the candidate understands why Web Forms is uniquely hard to migrate and can run a realistic incremental migration with a sensible choice of target.
Green flags
Red flags
A Web Forms page is a class that builds a control tree on every request. On a postback, the browser posts the whole form, including __VIEWSTATE and __EVENTTARGET, and the page replays its lifecycle to rebuild state and raise the right event.
GET /Orders.aspx -> Init -> Load -> PreRender -> SaveViewState -> Render (HTML + __VIEWSTATE)
POST /Orders.aspx -> Init -> LoadViewState -> LoadPostData -> Load
-> RaisePostBackEvent (Button1_Click) -> PreRender -> SaveViewState -> Render
That model hides HTTP from the developer, which is why teams loved it and why it can't be translated mechanically: modern frameworks expose HTTP or component state explicitly.
Code-behind often mixes data access, validation and rules:
Orders.aspx.cs
btnApprove_Click -> SQL update + email + audit + UI change
Refactor it into an application service (IOrderApprovalService.ApproveAsync) in a class library that multi-targets net48;net10.0. Web Forms calls it today; Blazor or Razor Pages calls it tomorrow. Characterisation tests pin the behaviour before you move it.
Browser
|
ASP.NET Core 10 app (YARP + new pages)
|-- /orders/* -> new Blazor/Razor pages
|-- /reports/* -> new pages
'-- /{**catch-all} -> YARP -> Web Forms app on IIS (.NET Framework 4.8)
Shared: authentication (remote auth or shared cookie), session (remote or Redis), database
URLs often change (/Orders.aspx?id=5 to /orders/5); add redirects in the new app so bookmarks keep working.
Microsoft.AspNetCore.SystemWebAdapters): remote authentication lets the new app ask the old app who the user is; remote session lets it read and write the old app's session through an endpoint (session values must be serialisable with registered key serialisers).Microsoft.Owin.Security.Interop), so either can sign the user in..NET 8+ Blazor Web Apps choose per component: static SSR (plain HTML, like Razor Pages), Interactive Server (events over a SignalR circuit, state on the server: closest to Web Forms), Interactive WebAssembly (runs in the browser), or Auto. Interactive Server costs memory per connected user (often tens to hundreds of KB per circuit) and needs sticky sessions or Azure SignalR Service when scaled out.
Score pages by business value, change frequency and risk. Migrate a low-risk, high-traffic page first to prove the topology, then the pages that change most often (so new features are built once, in the new stack). Leave rarely used admin pages until last; some can simply be deleted.
__VIEWSTATE.Click handler into a service with a characterisation test, called from the page.Before: a Web Forms page with logic in code-behind.
// BEFORE: Orders.aspx.cs (.NET Framework 4.8)
public partial class Orders : System.Web.UI.Page
{
protected void btnApprove_Click(object sender, EventArgs e)
{
var id = int.Parse(hfOrderId.Value);
using var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Main"].ConnectionString);
conn.Open();
new SqlCommand($"UPDATE Orders SET Status='Approved' WHERE Id={id}", conn).ExecuteNonQuery(); // SQL injection
lblMessage.Text = "Approved";
gvOrders.DataBind();
}
}
Step 1: extract the rule into a service both UIs can call.
namespace Contoso.Orders.Application;
public interface IOrderApprovalService
{
Task
.aspx pages. Instead: add permanent redirects in the new app.Web Forms migrations fail on funding, not technology. The page-by-page approach matters because it turns a long project into a stream of visible improvements; I report progress as the percentage of requests served by the new app, which the business understands. I'm also willing to leave the Web Forms app alone if it is stable and rarely changed: .NET Framework 4.8.1 is supported as part of Windows, and the money may be better spent elsewhere.
On the target, choose for the team that will maintain it. Blazor's familiarity with Web Forms developers is a real advantage, not a soft one.
| Strategy | When it fits | Cost | When not to |
|---|---|---|---|
| Page by page behind YARP | Large, actively changed app | Proxy, shared auth, two apps for a while | Tiny app: rewrite directly |
| Extract logic, keep Web Forms UI | Stable UI, logic needs reuse | Low | UI itself is the problem |
| Leave as is on 4.8.1 | Stable, rarely changed, retiring | Rising skills and hosting risk | Needs new features often |
| Full rewrite | Small app or radically new requirements | High risk, frozen features | Business-critical with weak specs |
Web Forms (2002) made web development feel like Windows Forms: drag server controls onto a page, double-click a button, write a Click handler in code-behind. It hides HTTP's statelessness with two tricks: postbacks (interactions POST the form back to the same page) and ViewState (a hidden field, signed by default and optionally encrypted, that carries control state between requests). Each request runs the page lifecycle: Init, Load, the postback event, PreRender, Render. UpdatePanel can make a postback update only part of the page, but the server still runs the whole lifecycle.
It is productive for forms-over-data apps, but pages get heavy, logic hides in code-behind and it is hard to test. It is built on System.Web, so it never came to modern .NET. Blazor is the closest in feel, Razor Pages the closest in structure, an SPA plus API another option. The trade-off: no tool converts it automatically; migration is page by page.
In-process session lives in the w3wp.exe memory, so users are pinned to one server (sticky sessions) and lose state on every app pool recycle. Switch <sessionState mode="SQLServer"> or a Redis provider (for example Azure Cache for Redis) so session survives recycles and works across servers, which improves availability and lets you scale out. This forces session objects to be serialisable and adds a store round trip per request, which flushes out large or non-serialisable objects: measure session size and trim it. It also prepares the migration: ASP.NET Core has no in-process Session by default, its session sits on IDistributedCache, and the System.Web adapters' remote session lets a new ASP.NET Core app read the legacy app's session during an incremental, page-by-page move so users don't notice the switch.
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.
How to tell it (STAR)
**S:** We were moving [an internal case-management Web Forms app] to Blazor one page at a time. **T:** The busiest page was slow and the team had avoided migrating it, so I took it on. **A:** I measured it: [400 KB] of ViewState from a grid holding the whole result set. As a quick win I disabled ViewState and added server-side paging in Web Forms. Then I extracted the search logic into a tested service and rebuilt the page in Blazor, routed through YARP. **R:** Load time went from [2.8 s] to [0.9 s], and once the hardest page was done the team's pace picked up to [10 pages a sprint].
Last updated 23 Nov 2026.