Add additional Blazor migration guidance for upgrading to .NET 8
We've received some feedback that our Blazor migration guidance is too minimalistic and doesn't cover all of the related concerns:
- Apps using lazy loading were impacted by the change to webcil, which changed the assembly extension from .dll to .wasm
- We changed our authentication guidance in .NET 8, but we didn't give detailed instructions on how to upgrade
Why does the <title> has to be removed? This ensured a consistent title for the web app across all the pages.
@SeanFeldman ... The App component of a BWA doesn't set the page title that way ...
https://github.com/dotnet/aspnetcore/blob/main/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWeb-CSharp/Components/App.razor
Page titles are specified via the HeadOutlet/PageTitle components ...
https://learn.microsoft.com/en-us/aspnet/core/blazor/components/control-head-content?view=aspnetcore-8.0#control-head-content-in-a-razor-component
I'll cross-link that guidance for that change when I reach this issue.
It might still be possible to use a <title> tag for an app-wide fallback (possibly depending on ordering, too), but I don't recall if there are artifacts of using it ... i.e., 🐉😈. The idea here is to convert the app to a BWA, not try to maintain hosted WASM solution conventions, so that's why we're angling to have devs drop it for the migration guidance. It truly is a conversion to a BWA, not merely an updated/upgraded hosted WASM solution.
You can apply a PageTitle component to a layout to get it for all of the components that don't specify their own PageTitle component. For example in Components/Layout/MainLayout.razor ...
<PageTitle>Page Title</PageTitle>
It can also be placed in the App component in the <head> content ...
<head>
...
<HeadOutlet />
<PageTitle>Page Title</PageTitle>
</head>
When I reach this issue, I'll update the Control <head> content and Migration articles.
@danroth27 ...
We changed our authentication guidance in .NET 8, but we didn't give detailed instructions on how to upgrade
Are we migrating users to the BFF or non-BFF pattern?
We should consider creating a new Migration node article if we're going to place that much guidance. I can take the current hosted WASM to BWA piece we have now to get it started, then I can add the auth conversion steps.
@guardrex, another missing guidance is about anti-forgery. The documentation shows half of what needs to be done, omitting the required builder.Services.AddAntiforgery() part
@SeanFeldman ... When AddRazorComponents is called, the antiforgery services are added ✨ automagically ✨...
https://github.com/dotnet/aspnetcore/blob/main/src/Components/Endpoints/src/DependencyInjection/RazorComponentsServiceCollectionExtensions.cs#L40
I'll make a note of it in passing in the migration guidance ... and I know at least one other spot in the Blazor security docs where a remark on this should appear. I'll also check our forms security content to see if a remark should appear there as well. Thanks for mentioning it. 🍻
Copying over my remarks on the auth situation ...
... it sounds like some of the auth targets for migration are still in the works. Later, I'll need clarification on the exact starting points.
Examples of scenarios that we didn't cover in the Blazor node:
- Duende backend for Blazor WASM, which I suppose is the 7.0 starting point for the 8.0 Standalone with Identity (
MapIdentityApi) article+sample target.- Blazor Server+Duende, which I suppose is the 7.0 starting point for the 8.0 BWA+OIDC (non-BFF?) article+sample.
- Blazor Server+Entra, which is obviously the 7.0 starting point for 8.0 BWA+Entra. IIRC, the Azure folks were going to put up samples for BWA+Entra and BWA+B2C. I see you're saying now that Halter will create the target (at least for Entra), so I'll just need to start with a Blazor Server+Entra app.
I think that WASM+Entra/B2C doesn't require more than package and TFM changes, which are already covered by the existing migration guidance.