Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Access ASP.NET Core Blazor static files from asset in css

$
0
0

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"); }

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>