Description
We should add migration steps to this doc that describe how to update an existing ASP.NET Core app to use MapStaticAssets in .NET 9. Note that this is an optional step and is not required to update to .NET 9, but it does enable new functionality and benefits.
- Replace
UseStaticFiles with MapStaticAssets in Program.cs
- In Blazor Web Apps apps
- Update explicit references to static assets in .razor files to use the
@Assets["asset-path"] API
- Note, this should not be done for the Blazor framework scripts (blazor.*.js)
- Update your root App.razor component to include the
<ImportMap /> component in the head
- In MVC & Razor Pages based apps
- Chain a call to
.WithStaticAssets() after MapRazorPages or MapControllerRoute in Program.cs
- Add
<script type="importmap"></script> to the head of the main layout
@javiercn Anything else?
Page URL
https://learn.microsoft.com/en-us/aspnet/core/migration/80-90?view=aspnetcore-8.0&tabs=visual-studio
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/migration/80-90.md
Document ID
ff7b9e49-f8a8-552a-e27e-c604c858b318
Article author
@Rick-Anderson
Related Issues
Associated WorkItem - 340228
Description
We should add migration steps to this doc that describe how to update an existing ASP.NET Core app to use MapStaticAssets in .NET 9. Note that this is an optional step and is not required to update to .NET 9, but it does enable new functionality and benefits.
UseStaticFileswithMapStaticAssetsin Program.cs@Assets["asset-path"]API<ImportMap />component in the head.WithStaticAssets()afterMapRazorPagesorMapControllerRoutein Program.cs<script type="importmap"></script>to the head of the main layout@javiercn Anything else?
Page URL
https://learn.microsoft.com/en-us/aspnet/core/migration/80-90?view=aspnetcore-8.0&tabs=visual-studio
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/migration/80-90.md
Document ID
ff7b9e49-f8a8-552a-e27e-c604c858b318
Article author
@Rick-Anderson
Related Issues
Associated WorkItem - 340228