Modernising a legacy ASP.NET frontend: what actually happened
A quick note: this project is under NDA, so I’ve anonymised the client and left out screenshots. The numbers, code snippets and commit messages are real.
About ten months ago I wrote a cheery little post about modernising a decade-old ASP.NET eCommerce platform with Alpine.js and Tailwind. I called the stack “TALA”, talked about how great Pines UI is, and used phrases like “a genuine no brainer”.
I’ve since taken that post down, because I was wrong. Not slightly wrong, either. I was confidently, cheerfully wrong, in the way you can only be before you’ve actually started.
My favourite line from it: “the actual ASP logic wasn’t overly complex and worked fine. It just needed to look and feel better.”
Spoiler: it did not just need to look and feel better.
I thought this was a frontend project with a nice stack attached. It turned out to be about ownership, scope and expectations, and most of the obstacles were things no amount of code could fix.
The setup
The platform is a custom .NET eCommerce site for an aesthetics brand. It sells B2B and B2C products, offers, training courses and webinars, and it operates under strict UK regulations: who can buy what, at what price, with which credentials. That’s why it was never on Shopify. Very little of it fits neatly into an off-the-shelf platform or CRM.
It’s also not a side project. Over £10m of trade passes through the site every year, much of it from professionals who reorder regularly and rely on it working. Breaking checkout for an afternoon isn’t a funny anecdote here; it’s real money and real customers’ clinics.
My role started as “developer and CRO person who’ll modernise the frontend”. It quickly became broader.
I was the only technical specialist on the project, alongside a project manager and a designer. The backend belonged to a separate team, fully (and rightly) committed to moving the business onto a new ERP. The designs were ambitious, drawn for the platform the business wanted rather than the one it had, and the business wanted it done fast.
So the job was really three jobs: technical strategist, translator between design, leadership and the backend, and the person writing the code.
Before any code: working out what we actually had
My toxic trait first instinct was “scrap it and rebuild in Next.js”. I got the backend team to generate Swagger docs, mocked up a headless frontend, planned the auth middleware, and put together a presentation on headless architecture.
Then I did the less exciting thing and wrote an options paper. Three routes, roughly costed:
| Option | Difficulty | Cost | Time |
|---|---|---|---|
| 1. Update the existing ASP.NET frontend | 2/5 | 1/5 | 2–3 months |
| 2. New headless frontend (e.g. Next.js) on the existing backend | 5/5 | 1/5 | 6 months+ |
| 3. Off-the-shelf ERP/commerce platform | 1/5 | 5/5 | Unknown |
Option 1 had conditions attached, and I listed them as blockers in the paper:
- Backend visibility. Read-only access to the backend code and documentation, so we could understand why things broke or ran slowly.
- A real dev environment. Version control and a database snapshot, so changes could be tested against realistic data instead of deployed and eyeballed.
- Stable data contracts. The backend migration should keep existing endpoints and data shapes, so frontend work didn’t have to wait for it.
A couple of months in, I followed that with a fuller platform review for leadership. The headline finding:
The website is a frontend shell. Orders, pricing, offers, roles, product visibility, ERP sync: all the real business logic lives in a separate backend API that we can’t see into.
That changed the conversation, because an agency rebuild, a headless frontend and a platform migration all hit the same wall. The review asked three questions nobody had formally asked:
- Who owns the backend code?
- What are our rights if that relationship changes?
- And what is the ERP migration changing in the API?
My recommendation: if we rebuild anything, rebuild the frontend only and leave the backend alone. Rewriting all that regulated business logic would take years, and nobody had the time or budget for it.
That platform review is probably the most useful thing I produced on the project, and there isn’t a line of code in it.
Fighting for scope
The answers all pointed the same way. With no backend capacity, headless was off the table, the dev environment never materialised, and backend access stayed at “here’s a Swagger page”. That left Option 1, with none of its conditions met.
From then on, a big part of my week was translating designs into cost. A component that looked like a small visual change might sit on top of 1,500 lines of inline jQuery and a backend response I couldn’t change. When designs moved mid-build, or someone asked “can we make the site faster?”, I was the one explaining what that really meant.
Nobody was being unreasonable. But as the only technical person in the room, I was the one who kept saying “yes, but”, and I didn’t always say it well, or early enough.
What 10 years of Razor actually looks like
To make the scope argument, I needed numbers. “Some files stretch to 5,000+ lines”, as I put it in the original post, massively undersold it:
| Thing | Count |
|---|---|
.cshtml views | 729 files, ~547,000 lines |
| Distinct backend API routes referenced | ~1,026 |
id="…" attributes in views | 23,962 |
Inline onclick= handlers | 4,044 |
<script> tags inside views | 2,756 |
.modal('show'/'hide') calls | ~1,078 |
!important in the SCSS | 1,153 |
Hand-listed files in the .csproj | 3,274 |
The number that matters is the IDs. They aren’t styling hooks. The markup is the API between Razor, inline jQuery, Kendo widgets and the backend’s response shapes. Rename a <div> on one page and you might break a feature on a page you’ve never opened.
Attempt #1: the clean rewrite
Even inside Option 1, I tried to keep a path open to something modern. The plan was a Strangler Fig: build the new site around the old one and replace it piece by piece until nothing of the original is left.
In practice, that meant backing up old views as v1 files, writing new ones from scratch in Tailwind and Alpine on a parallel v2 layout, adding new JSON endpoints, and porting pages one by one from my prototype. If the backend ever opened up, v2 could become the headless frontend.
About two months in, I made the call to stop. The reasons:
- The data contract was frozen. One commit message reads “Replacing .NET banner logic with new Alpine, will eventually update models”. “Eventually” depended on backend capacity that wasn’t coming, so rebuilding the basket in Alpine didn’t improve it; it cloned it, quirks and all.
- Alpine meant rewriting too much jQuery. The state lived in thousands of jQuery handlers, Kendo widgets and AJAX callbacks that touch the DOM directly. Making Alpine the source of truth meant rewriting all of them.
- The patchwork didn’t scale. Strangler Fig works when you can see the finish line. With 729 views, old and new halves had to share a basket, a header and a checkout, and every ported page added more seams.
- A parallel layout doubled the surface area. Every fix had to land in v1 and v2.
That was a hard decision to make alone, two months into a project with a deadline. But continuing would have meant delivering half of two sites instead of all of one.
Attempt #2: change the look, never the behaviour
The new strategy fitted on one line:
Change look, never behaviour. Preserve every
id,name, JS-hook class, everyonclick, and the DOM structure JS reads.
Restyle in place, and where possible, fix whole categories of problems with one global layer instead of touching hundreds of call sites. Alpine stayed only where it’s genuinely the right tool: drawers, the header, the cart counter and search.
A few examples:
- One modal coordinator instead of 1,078 edits. Bootstrap 4 stacks modals badly, and the basket had its own custom overlay on top. A 75-line
modal.jslistens to Bootstrap’s ownshow/hiddenevents, assigns z-indexes, and derives scrim visibility from state, so double or orphaned scrims become structurally impossible. No call sites changed. - One toast system. Instead of editing every page’s success and error banners, I rewired the helper functions they already called to fire a single global
toast(). - One
:has()selector. About a dozen FAQ, legal and account pages shared a Bootstrap sidebar layout. One rule turned all of them into a CSS grid:
.row:has(> .index) {
display: grid;
grid-template-columns: 1fr 2fr;
gap: 0.75rem;
}
- A written playbook. A 10-step checklist per page, and a strict definition of “done”: checked on desktop and mobile, and every interactive control still works.
The hardest discipline was leaving bugs alone. A missing + in a jQuery template that broke a tab for real customers was a markup bug, so I fixed it. But behaviour bugs (pagination calling a function copy-pasted from another page, date formats toggled by commenting out lines before deploy, localhost URLs saved into production data) couldn’t be tested safely without backend access. They went on a list for someone who could.
The speed wall, and why I measured it
The site feels slow, and leadership understandably hoped the redesign would fix that. I couldn’t argue that it wouldn’t without evidence, so I built a small diagnostics layer that adds a Server-Timing header to every response, splitting backend API time from our own web code:
| Page | Time to first byte |
|---|---|
| Static asset | ~0.09s |
Privacy policy (controller literally does return View()) | ~1.5s |
| Homepage | ~1.8–1.9s |
| Product listing | ~5s |
Locally, the full layout renders in about 55ms. In production, a near-static page costs 1.5s because every page makes several synchronous, sequential calls to the backend before it can render. Nothing is async, so the calls can’t overlap.
That table did more in one meeting than weeks of “it’s the backend, honestly”. It also answered a question that was starting to circulate: migrating the web tier to .NET Core wouldn’t help. That’s an expensive project avoided.
What I could do from my side, I did: removed a category list that was fetched three times per page, cached the homepage so a warm load makes zero backend calls, converted 548 images to WebP (155MB → 16.5MB), and added hover-prefetching to hide some of the latency. The foundational fixes stay on the other side of the wall.
What “modernised” ended up meaning
| Wanted | Got |
|---|---|
| New design across the site | Yes. Homepage, nav, listings, product pages, basket, checkout, account pages, offers, training, legal |
| Modern Tailwind/Alpine frontend | No. SCSS ports of the prototype over Bootstrap, with Alpine in a handful of key places |
| A faster site | Partly. Lighter images, cached homepage, perceived speed via prefetch. The 1.5s floor is backend-bound |
| Clean data contracts | No. Out of the frontend’s reach |
| A clear long-term architecture decision | Yes. Frontend-only rebuild against the existing API, with the ownership questions on the table |
| 2–3 months | About 4 months of build, with a full change of direction halfway through |
What I’d tell myself ten months ago
If you’re the only technical person, the strategy is your job too. Nobody else will write the options paper, ask who owns the backend, or explain why a design change costs three weeks. Do it early and in writing, and put the conditions in the document so you can point back at them later.
Find out who owns the data contract before choosing a stack. Alpine and Tailwind weren’t the wrong tools. They were the wrong strategy for a frontend whose state belongs to someone else.
“Modernise” can quietly mean “reskin”. If you can’t change the data layer, you’re doing a reskin. That can still be a big improvement, but call it that from day one. It makes every later scope conversation easier.
Some walls aren’t yours to move, but you can make them visible. I couldn’t fix the backend, get a dev environment, or freeze the designs. What I could do was make the constraints clear enough that the next decision (agency, rebuild, or neither) gets made with the full picture.
For the record, I still think Alpine and Tailwind is a lovely stack. I’ll use it properly one day, on a project where I own the data.