Skip to content

Commit

Permalink
MapStaticAssets to migration /2 (#34004)
Browse files Browse the repository at this point in the history
* MapStaticAssets to migration /2

* MapStaticAssets to migration /2

* MapStaticAssets to migration /2
  • Loading branch information
Rick-Anderson authored Nov 5, 2024
1 parent 56dcd10 commit 39324ff
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions aspnetcore/migration/80-90.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,29 @@ In the project file, update each [`Microsoft.AspNetCore.*`](https://www.nuget.or
- <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.2" />
- <PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
- <PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
+ <PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="9.0.0-preview.1.24081.5" />
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0-preview.1.24081.2" />
+ <PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="9.0.0-preview.1.24080.9" />
+ <PackageReference Include="System.Net.Http.Json" Version="9.0.0-preview.1.24080.9" />
+ <PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="9.0.0" />
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="9.0.0" />
+ <PackageReference Include="System.Net.Http.Json" Version="9.0.0" />
</ItemGroup>
```

## Replace UseStaticFiles with MapStaticAssets

Blazor has different update instructions for `MapStaticAssets` than Razor Pages and ASP.NET Core MVC.

### 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 the root `App.razor` component to include the `<ImportMap />` component in the head.

### 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 <xref:fundamentals/static-files?view=aspnetcore-9.0&preserve-view=true>
* Add `<script type="importmap"></script>` to the head of the main layout file.

## Blazor

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

0 comments on commit 39324ff

Please sign in to comment.