convert-blazor-server-to-webapp

Migrates pre-.NET 8 Blazor Server apps to the .NET 8+ Blazor Web App model.

Updated Jul 2, 2026
One-click install
npx skills add https://github.com/ecoDriverltd/FoundryAgentsExperiment --skill convert-blazor-server-to-webapp-ecodriverltd
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: convert-blazor-server-to-webapp
Source: https://github.com/ecoDriverltd/FoundryAgentsExperiment/tree/main/.agents/skills/convert-blazor-server-to-webapp
Command: npx skills add https://github.com/ecoDriverltd/FoundryAgentsExperiment --skill convert-blazor-server-to-webapp-ecodriverltd

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Migrating a legacy Blazor Server app to the modern .NET 8+ Blazor Web App model involves many coordinated changes across the project file, Program.cs, _Host.cshtml, and App.razor, and missing any step causes subtle runtime failures like broken antiforgery or lost circuit options. ## Core Features & Use Cases - Step-by-step migration workflow: Updates the .csproj TFM, converts _Host.cshtml into an App.razor root component, moves the Router into Routes.razor, and rewrites Program.cs to use AddRazorComponents and MapRazorComponents. - Authentication migration: Replaces the CascadingAuthenticationState component wrapper with the AddCascadingAuthenticationState service, which works across render mode boundaries. - Validation checklist and pitfalls table: Verifies no references to AddServerSideBlazor, MapBlazorHub, or blazor.server.js remain, and covers common failures like missing UseAntiforgery middleware. - Use Case: You have a .NET 7 Blazor Server app using Pages/_Host.cshtml and want to upgrade to .NET 8 with InteractiveServer render mode while preserving existing behavior. ## Quick Start Convert my Blazor Server project in this repo to a .NET 8 Blazor Web App using the InteractiveServer render mode.

Frequently Asked Questions about convert-blazor-server-to-webapp

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert a Blazor Server app to a Blazor Web App in .NET 8?▼

Update the TFM to net8.0, move the Router from App.razor into a new Routes.razor, convert Pages/_Host.cshtml into an App.razor root component, and replace AddServerSideBlazor/MapBlazorHub with AddRazorComponents().AddInteractiveServerComponents() and MapRazorComponents<App>().AddInteractiveServerRenderMode().

How to migrate _Host.cshtml to App.razor in Blazor?▼

Move the HTML shell from _Host.cshtml into App.razor, remove Razor Page directives and tag helpers, replace the Component Tag Helpers with <HeadOutlet @rendermode="InteractiveServer" /> and <Routes @rendermode="InteractiveServer" />, change blazor.server.js to blazor.web.js, then delete _Host.cshtml.

Why do form POST requests return 400 errors after migrating to Blazor Web App?▼

The antiforgery middleware is missing. AddRazorComponents registers antiforgery services but you must explicitly add app.UseAntiforgery() to the pipeline, placed after UseAuthentication and UseAuthorization.

Does CascadingAuthenticationState work in Blazor Web Apps?▼

The <CascadingAuthenticationState> component wrapper does not work across render mode boundaries in Blazor Web Apps. Replace it with builder.Services.AddCascadingAuthenticationState() in Program.cs, which provides authentication state as a cascading value to all components.

When should I not convert a Blazor Server app to a Blazor Web App?▼

Skip conversion if the app already uses AddRazorComponents and MapRazorComponents, if it is a Blazor WebAssembly app (different migration path), if it should stay on the legacy Blazor Server model, or if it still targets .NET Framework.

How do I preserve disabled prerendering when migrating to InteractiveServer?▼

If the original app used render-mode="Server" instead of "ServerPrerendered", use new InteractiveServerRenderMode(prerender: false) for HeadOutlet and Routes instead of the InteractiveServer shorthand, which enables prerendering.