Client-Side ASP.NET MVC Runtime for WebAssembly #125144
Replies: 4 comments
-
|
Hi @sultanaalyami. Our web UI investments in ASP.NET Core are currently focused on Blazor, but we still support and maintain MVC and it's great to see the community experiment with the MVC model for client-side UI. I don't think this is something we'll bring directly into the platform, but it's certainly something the community can continue to experiment with. I believe all of the infrastructure pieces you mentioned can be handled outside of the framework, but if there are specific areas where you think better extensibility or composability are needed, please let us know. Regarding Native AOT specifically, that will generally help with runtime performance but will typically increase download size compared to the Jiterpreter approach. What makes AOT smaller for server runtimes is really IL trimming, which you'll want to do for client-side apps whether you AOT compile the code to WebAssembly or not. |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for the clarification. Just to understand better — if someone wants to experiment with MVC-style client-side UI outside the framework, would the recommended approach be building it as a separate library on top of ASP.NET Core, or extending existing Blazor infrastructure? Also, regarding Native AOT and IL trimming, are there any official guidelines or best practices for optimizing client-side apps compiled to WebAssembly? |
Beta Was this translation helpful? Give feedback.
-
|
This is a tracking sub-issue for following up on the progress and discussion related to the upstream issue in the .NET Runtime repository: Related issue: Client-Side ASP.NET MVC Runtime for WebAssembly (#125136) Please refer to the linked issue for technical details, the proposed solution, and ongoing feedback involving the client-side ASP.NET MVC runtime for WebAssembly. This sub-issue will help ensure synchronization between our project and any advancements or updates from the upstream thread. Action items:
|
Beta Was this translation helpful? Give feedback.
-
🚀 Official UpdateWe are excited to share that ASP.NET MVC now runs fully client‑side on WebAssembly, powered by the NetWasmMVC toolchain and hosted through Blazor. This milestone required significant effort, research, and engineering work — but the results are now live through two official templates: 🔐 Core Identity TemplateA complete MVC + Identity experience running entirely in the browser: 📱 SPA + PWA TemplateA single‑page MVC application with full PWA capabilities and offline support: Both templates are fully operational. ❤️ Support the ProjectThis work has required substantial time and resources. This marks the first production‑grade demonstration of client‑side MVC running on WebAssembly. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
This proposal introduces a client-side ASP.NET MVC runtime that executes Controllers, Razor Views, Routing, EF Core (SQLite), SignalR, and Identity entirely inside a WebAssembly Web Worker — with zero server dependency at runtime.
Developers write standard MVC code — Controllers,
.cshtmlViews,ViewData/ViewBag/TempData, Tag Helpers, Areas — and the SDK compiles it into static files deployable to any CDN, edge network, or embedded WebView.The Problem
ASP.NET MVC is the most widely adopted .NET web programming model — yet it has no client-side story.
Proposed Solution
A new SDK target that compiles ASP.NET MVC for execution inside a WebAssembly Web Worker:
The developer writes standard MVC code — no new paradigm to learn:
dotnet publishproduces static files. No ASP.NET server required at runtime.How it works: The .NET runtime boots inside a Web Worker, keeping the UI thread free. An MVC engine handles controller discovery, route matching, and action invocation. A pattern-matching Razor engine renders
.cshtmlviews from embedded resources. The rendered HTML is sent to the main thread as frames applied viarequestAnimationFrame. SQLite databases and session state persist to the Origin Private File System (OPFS). All C#↔JS communication uses JSImport/JSExport — no dependency on Blazor's infrastructure.What's included
Controllerbase class,ViewData/ViewBag/TempData/ModelState,ViewResult/PartialViewResult/JsonResult/RedirectResult, attribute routing,[Area],[ApiController], convention-based routing.@Model,@ViewData,@if/@foreach,@RenderBody(),@RenderSection(),@Html.PartialAsync(),asp-controller/asp-actiontag helpers.Clients.All/Caller/Others/Group(), connection management — all in-process.cepha new,cepha dev,cepha publish,cepha kit(Cepha.CLI).How this complements Blazor
This is not a replacement for Blazor. Blazor excels at rich interactive UIs with fine-grained reactivity. MVC WASM excels at document-oriented apps, admin panels, and CRUD applications where the existing MVC skillset should transfer directly to client-side deployment — without rewriting views as components. Both models share the same .NET WASM runtime and could coexist.
Why This Belongs in .NET 11
The runtime foundation is ready. .NET 10 ships mature WebAssembly support:
dotnet.js, Web Workers, JSImport/JSExport, WASM-compiled SQLite. What's missing is the MVC engine layer on top.NativeAOT for WASM is coming. .NET 11 is expected to advance NativeAOT/Trimming for WebAssembly, which would reduce the current ~15-25MB bundle to a competitive size. This proposal aligns with that timeline.
Edge computing is mainstream. Cloudflare Workers, Deno Deploy, Vercel Edge Functions are standard deployment targets. .NET 11 is the window to establish MVC as a viable edge framework.
Developer demand is real. MVC is the WIP: repo consolidation scouting kick-off - make clr build locally on Windows #1 ASP.NET programming model by adoption. Developers want their existing skills to work in new deployment targets — not a new paradigm.
Feasibility is proven. The reference implementation is published on NuGet with CI/CD, covering Controllers → Views → EF Core → Identity → SignalR. This is not theoretical.
What We Are Asking from the .NET Team
We are not asking for a massive new framework — just targeted infrastructure:
Experimental / .NET 11 Preview
Microsoft.NET.Sdk.WebAssembly.MvcSDK target — embed.cshtmlas resources, link SQLite natively, produce static SPA output. (~200 lines of MSBuild in our implementation.)MvcEnginefor WASM — controller discovery, route matching, action invocation without the full server pipeline. (Single file in our implementation.)ITemplateProvider/IRazorTemplateEngine) — rendering.cshtmlfrom embedded resources.dotnet new mvc-wasmtemplate — scaffolding via the standard template system.Post-Preview
What we are NOT asking for: ❌ Changes to the existing MVC server pipeline · ❌ Changes to Blazor · ❌ A new component model · ❌ Deprecation of any existing feature.
Reference Implementation
📦 Repository: github.com/sbay-dev/NetWasmMVCRuntime
NuGet packages:
NetWasmMvc.SDK—<Project Sdk="NetWasmMvc.SDK/1.0.6">Cepha.CLI—dotnet tool install --global Cepha.CLIKey source files:
MvcEngine.cs·RazorTemplateEngine.cs·Controller.cs·SignalREngine.cs·Identity/·CephaApp.cs·main.js·Sdk/Call for Feedback
We'd love to hear from the community and the .NET team:
If you find this idea interesting, please 👍 this discussion and share your use cases. Community signal helps the .NET team prioritize.
Based on WasmMvcRuntime — an open-source client-side ASP.NET MVC runtime for WebAssembly, published on NuGet and actively maintained.
Originally posted by @sultanaalyami in dotnet/aspnetcore#65501
Beta Was this translation helpful? Give feedback.
All reactions