dotnet / dotnet/AspNetCore.Docs

Static files endpoints optomization

Open
#37,424 0 comments 0 reactions 1 assignee Claimed by @wadepickett View on GitHub
aspnet-core/svc Source - Docs.ms tutorials/subsvc
Dominant language
C#
Stars
13.1k
Forks
24.6k
Avg merge
1d 3h
Merged PRs (30d)
97

Description

### Description

This has always confused me a little since the project template added it in.
So, I just wanted to try and document it.

For:
--------------------------
app.MapStaticAssets() : Optimizes the delivery of static assets in an app, such as HTML, CSS, images, and JavaScript. For more information, see [What's new in ASP.NET Core in .NET 9](https://learn.microsoft.com/en-us/aspnet/core/release-notes/aspnetcore-9.0?view=aspnetcore-10.0#optimizing-static-web-asset-delivery).

.WithStaticAssets(); : Ensures Razor Pages participate in the optimization system for static assets.
-----------------------
I believe app.MapStaticAssets simply maps end points to static files like:
www.css.site.css
It does no static file optimization.

app.MapRazorPages()
.WithStaticAssets()
opts the Razor Pages endpoints into static file optimization using metadata.

With WithStaticAssets(), the framework can emit something like:

/css/site.3F9A8C1.css

so the browser knows when the file has been updated.

### Page URL

https://learn.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/razor-pages-start?view=aspnetcore-10.0&tabs=visual-studio

### Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/tutorials/razor-pages/razor-pages-start.md

### Document ID

L2VuLXVzL2FzcG5ldC9jb3JlL3R1dG9yaWFscy9yYXpvci1wYWdlcy9yYXpvci1wYWdlcy1zdGFydA==

### Platform Id

b171f3de-4520-63d4-7b45-da14e27322a8

### Article author

@wadepickett

### Metadata

* ID: L2VuLXVzL2FzcG5ldC9jb3JlL3R1dG9yaWFscy9yYXpvci1wYWdlcy9yYXpvci1wYWdlcy1zdGFydA==
* PlatformId: b171f3de-4520-63d4-7b45-da14e27322a8
* Service: **aspnet-core**
* Sub-service: **tutorials**

[Related Issues](https://github.com/dotnet/AspNetCore.Docs/issues?q=is%3Aissue+is%3Aopen+5492c641-af15-64b8-beaa-ddf511be73e6)

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.