Migrate from Blazor Server to Blazor Web App#447
Conversation
Co-authored-by: linkdotnet <26365461+linkdotnet@users.noreply.github.com>
… empty code block Co-authored-by: linkdotnet <26365461+linkdotnet@users.noreply.github.com>
|
@copilot Good start. Login and Logout does not work. |
Co-authored-by: linkdotnet <26365461+linkdotnet@users.noreply.github.com>
Fixed in commit a240318. The issue was that Tested:
|
|
@copilot We dont have a notfound page or at least it is not working. Since dotnet 10 this is possivle: |
|
@copilot We dont have a notfound page or at least it is not working. Since dotnet 10 this is possivle: lazor router has a NotFoundPage parameter Blazor now provides an improved way to display a "Not Found" page when navigating to a non-existent page. You can specify a page to render when NavigationManager.NotFound (described in the next section) is invoked by passing a page type to the Router component using the NotFoundPage parameter. The feature supports routing, works across code Status Code Pages Re-execution Middleware, and is compatible even with non-Blazor scenarios. The NotFound render fragment (...) isn't supported in .NET 10 or later. razor Copy This content is ignored because NotFoundPage is defined. The Blazor project template now includes a NotFound.razor page by default. This page automatically renders whenever NavigationManager.NotFound is called in your app, making it easier to handle missing routes with a consistent user experience. For more information, see ASP.NET Core Blazor routing and navigation. |
…ute middleware Co-authored-by: linkdotnet <26365461+linkdotnet@users.noreply.github.com>
Fixed in commit 3ee8f39. Implemented .NET 10's NotFoundPage parameter feature:
The NotFound page now:
|
Migration from Blazor Server to Blazor Web App ✅
This PR successfully migrates the blog from Blazor Server to the Blazor Web App model (.NET 10).
Completed Tasks:
Key Changes (5 files modified, 1 file created):
AddServerSideBlazor()withAddRazorComponents().AddInteractiveServerComponents()MapBlazorHub()andMapFallbackToPage()withMapRazorComponents<App>().AddInteractiveServerRenderMode()AddAntiforgery()andUseAntiforgery()middlewareMapRazorPages()to support Login/Logout Razor PagesUseStatusCodePagesWithReExecute("/NotFound")for .NET 10 NotFoundPage supportblazor.server.jstoblazor.web.js<environment>tags with C# conditionals@rendermode RenderMode.InteractiveServerNotFoundPage="@typeof(NotFound)"parameter instead of deprecated<NotFound>render fragmentTesting Results:
blazor.web.jsBackwards Compatibility:
MapRazorPages()Security Summary:
No new security vulnerabilities introduced. The changes are minimal and focused on:
The migration maintains all existing security features including:
Migration Benefits:
Notes:
The NotFound page now uses .NET 10's NotFoundPage parameter instead of deprecated
<NotFound>render fragmentStatusCodePagesWithReExecute middleware ensures proper 404 status codes and content
The migration was done with minimal changes (only 5 files modified, 1 file created)
All existing functionality is preserved and tested
Login and Logout now work correctly with explicit
MapRazorPages()endpoint mappingFixes Use Blazor Web App #368
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.