dotnet / dotnet/AspNetCore.Docs

Update sample to use app.MapStaticAssets(staticAssetsManifestPath: myManifestKey);

Open
#33,059 1 comment 0 reactions 0 assignees View on GitHub
aspnet-core/svc code help wanted doc-idea fundamentals/subsvc Source - Docs.ms
Dominant language
C#
Stars
13.1k
Forks
24.6k
Avg merge
1d 3h
Merged PRs (30d)
97

Description

### Description

Update [the following code](https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/static-files/samples/9.x/MapStaticAssetsManifest/Program.cs#L38C2-L58C4) to use a manifest file and replace any `app.UseStaticFiles(new StaticFileOptions` code with
```
var myManifestKey = builder.Configuration["MyManifestPath"]
?? "manifests/manifest.json";

/// other code

app.MapStaticAssets(staticAssetsManifestPath: myManifestKey);
```
Helpful links:
* [The new format of manifest file](https://github.com/dotnet/aspnetcore/issues/40369)
* [StaticAssetsIntegrationTests.cs](https://github.com/dotnet/aspnetcore/blob/main/src/StaticAssets/test/StaticAssetsIntegrationTests.cs)
* [StaticAssetsManifest](StaticAssetsManifest.cs)
* [StaticAssetsManifestPath](https://source.dot.net/Microsoft.AspNetCore.Components.WebAssembly.Server/R/23a221f155f0a67e.html)
* [StaticAssetsEndpointRouteBuilderExtensions](https://source.dot.net/Microsoft.AspNetCore.StaticAssets/R/a72721e0ebe486b8.html)

### Page URL

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-8.0

### Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/static-files.md

### Document ID

3fec6e08-fc99-7a5c-796f-3f2347cad891

### Article author

@Rick-Anderson

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.