From 3c5057d0cfb925fbcfa8aa8d6e0fbab40dba0d8d Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Mon, 4 Nov 2024 15:15:10 -1000 Subject: [PATCH 1/3] MapStaticAssets to migration /2 --- aspnetcore/migration/80-90.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/aspnetcore/migration/80-90.md b/aspnetcore/migration/80-90.md index 125c642e0480..8a48be35c40f 100644 --- a/aspnetcore/migration/80-90.md +++ b/aspnetcore/migration/80-90.md @@ -70,6 +70,22 @@ In the project file, update each [`Microsoft.AspNetCore.*`](https://www.nuget.or ``` +## Replace UseStaticFiles with MapStaticAssets + +Blazor has different update instructions than Razor Pages and ASP.NET Core MVC. + +### Blazor + +* Replace [UseStaticFiles](/dotnet/api/microsoft.aspnetcore.builder.staticfileextensions.usestaticfiles) with [MapStaticAssets](/dotnet/api/microsoft.aspnetcore.builder.staticassetsendpointroutebuilderextensions.mapstaticassets) in `Program.cs` +* Update explicit references to static assets in .razor files to use the `@Assets["asset-path"]` API. This should ***NOT*** be done for the Blazor framework scripts (`*blazor.\*.js*`) +* Update the root `App.razor` component to include the `` component in the head. + +### Razor Pages and ASP.NET Core MVC + +* Replace [UseStaticFiles](/dotnet/api/microsoft.aspnetcore.builder.staticfileextensions.usestaticfiles) with [MapStaticAssets](/dotnet/api/microsoft.aspnetcore.builder.staticassetsendpointroutebuilderextensions.mapstaticassets) in `Program.cs` +* Chain a call to `.WithStaticAssets` after `MapRazorPages` or `MapControllerRoute` in `Program.cs`. For an example, see the +* Add `` to the head of the main layout file. + ## Blazor [!INCLUDE[](~/migration/80-to-90/includes/blazor.md)] From edef6342f19d768bd750e1bad64bfc1020e34646 Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Mon, 4 Nov 2024 15:26:10 -1000 Subject: [PATCH 2/3] MapStaticAssets to migration /2 --- aspnetcore/migration/80-90.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aspnetcore/migration/80-90.md b/aspnetcore/migration/80-90.md index 8a48be35c40f..25d8000b706d 100644 --- a/aspnetcore/migration/80-90.md +++ b/aspnetcore/migration/80-90.md @@ -72,15 +72,15 @@ In the project file, update each [`Microsoft.AspNetCore.*`](https://www.nuget.or ## Replace UseStaticFiles with MapStaticAssets -Blazor has different update instructions than Razor Pages and ASP.NET Core MVC. +Blazor has different update instructions for `MapStaticAssets` than Razor Pages and ASP.NET Core MVC. -### Blazor +### Blazor web apps * Replace [UseStaticFiles](/dotnet/api/microsoft.aspnetcore.builder.staticfileextensions.usestaticfiles) with [MapStaticAssets](/dotnet/api/microsoft.aspnetcore.builder.staticassetsendpointroutebuilderextensions.mapstaticassets) in `Program.cs` -* Update explicit references to static assets in .razor files to use the `@Assets["asset-path"]` API. This should ***NOT*** be done for the Blazor framework scripts (`*blazor.\*.js*`) +* Update explicit references to static assets in `.razor` files to use the `@Assets["asset-path"]` API. This should ***NOT*** be done for the Blazor framework scripts (`*blazor.\*.js*`). * Update the root `App.razor` component to include the `` component in the head. -### Razor Pages and ASP.NET Core MVC +### Razor Pages and ASP.NET Core MVC based apps * Replace [UseStaticFiles](/dotnet/api/microsoft.aspnetcore.builder.staticfileextensions.usestaticfiles) with [MapStaticAssets](/dotnet/api/microsoft.aspnetcore.builder.staticassetsendpointroutebuilderextensions.mapstaticassets) in `Program.cs` * Chain a call to `.WithStaticAssets` after `MapRazorPages` or `MapControllerRoute` in `Program.cs`. For an example, see the From b54d886eaff467bdaed4c88fdb5b52f4b631a073 Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Mon, 4 Nov 2024 15:28:05 -1000 Subject: [PATCH 3/3] MapStaticAssets to migration /2 --- aspnetcore/migration/80-90.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aspnetcore/migration/80-90.md b/aspnetcore/migration/80-90.md index 25d8000b706d..a32a5682b719 100644 --- a/aspnetcore/migration/80-90.md +++ b/aspnetcore/migration/80-90.md @@ -63,10 +63,10 @@ In the project file, update each [`Microsoft.AspNetCore.*`](https://www.nuget.or - - - -+ -+ -+ -+ ++ ++ ++ ++ ```