Allow Assets API to emit lowercase URLs for fingerprinted assets
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
In ASP.NET Core 9, the new Assets API generates fingerprinted asset URLs that preserve the original casing of the project and file names (e.g., `_content/MyApp/MyApp.{fingerprint}.bundle.scp.css`). However, in production environments, it's common to enforce lowercase URLs for SEO, consistency, and caching efficiency. When using middleware that redirects all URLs to lowercase, these fingerprinted asset URLs get redirected unnecessarily, breaking caching and introducing unnecessary overhead.
### Describe the solution you'd like
I'd love to see a way to configure the Assets API to emit lowercase URLs for fingerprinted assets, including both the `_content/{project}` segment and the file names. An options object or extension method would be ideal. Something like:
`services.AddStaticAssets(options => options.UseLowercaseUrls = true);`
In the meantime, I've worked around the issue by excluding `_content/` requests from URL rewriting using `app.UseWhen()`. This is effective but feels like a workaround. Built-in support would be preferable.
### Additional context
This request is similar in spirit to `RouteOptions.LowercaseUrls`, which enables consistent lowercase route generation. A unified lowercase URL strategy across both routes and static assets would be highly beneficial in production environments.
Really appreciate the addition of the Assets API in .NET 9. It's a great step forward for managing static content and cache-busting in modern web apps. Just hoping for a little more flexibility here.
**NOTE:**
While it's true that [StaticWebAssetBasePath](https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/static-files?view=aspnetcore-9.0#static-web-asset-base-path) can be set to cause the entire base path to be lowercase, this does not force the file name itself to be lowercase as well (e.g., `_content/can_be_forced_lowercase/MyApp.{fingerprint}.bundle.scp.css`).
Contributor guide
Assessment
This issue has not been assessed yet.