Skip to content

Commit 3c5057d

Browse files
committed
MapStaticAssets to migration /2
1 parent 2060a96 commit 3c5057d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

aspnetcore/migration/80-90.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,22 @@ In the project file, update each [`Microsoft.AspNetCore.*`](https://www.nuget.or
7070
</ItemGroup>
7171
```
7272

73+
## Replace UseStaticFiles with MapStaticAssets
74+
75+
Blazor has different update instructions than Razor Pages and ASP.NET Core MVC.
76+
77+
### Blazor
78+
79+
* Replace [UseStaticFiles](/dotnet/api/microsoft.aspnetcore.builder.staticfileextensions.usestaticfiles) with [MapStaticAssets](/dotnet/api/microsoft.aspnetcore.builder.staticassetsendpointroutebuilderextensions.mapstaticassets) in `Program.cs`
80+
* 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*`)
81+
* Update the root `App.razor` component to include the `<ImportMap />` component in the head.
82+
83+
### Razor Pages and ASP.NET Core MVC
84+
85+
* Replace [UseStaticFiles](/dotnet/api/microsoft.aspnetcore.builder.staticfileextensions.usestaticfiles) with [MapStaticAssets](/dotnet/api/microsoft.aspnetcore.builder.staticassetsendpointroutebuilderextensions.mapstaticassets) in `Program.cs`
86+
* Chain a call to `.WithStaticAssets` after `MapRazorPages` or `MapControllerRoute` in `Program.cs`. For an example, see the <xref:fundamentals/static-files?view=aspnetcore-9.0&preserve-view=true>
87+
* Add `<script type="importmap"></script>` to the head of the main layout file.
88+
7389
## Blazor
7490

7591
[!INCLUDE[](~/migration/80-to-90/includes/blazor.md)]

0 commit comments

Comments
 (0)