The new MapStaticAssets feature in .NET 9.0 optimizes the delivery of static asset files, solving various problems such as preventing browsers from using old or stale assets and enabling the serving of compressed asset versions. To use a static file from an asset in a Razor component, you simply need to declare its path using the @Asset directive. Example:
<img src="@Assets["/images/picture.jpg"]" />However, how do you access your file from an asset when not in a Razor component, such as when setting a background image in CSS?Example:
.section { background-image: url("images/background.jpg"); }