Search code examples
.netasp.net-coreblazorblazor-webassembly

Blazor wasm RCL static assets are not accessible directly via url in browser in net 8


I have a .net8 blazor wasm app with the following structure

| - Demo.sln
    | - BlazorWASM.csproj
    |   - wwwroot
    |       - image.png
    | - RCL.csproj
    |   - wwwroot
    |       - rclimage.png

when I access the above static asset, the following happens

Action Observation
https://localhost/image.png ✅ This works
https://localhost/rclimage.png 🔴 This doesn't work

I have RCL.csproj added as dependency to BlazorWASM.csproj and I can access the rclimage.png normally in html using <img src="./_content/RCL/rclimage.png" /> but not directly in browser using https://localhost/rclimage.png. Please assist me on what I'm missing.


Solution

  • It's an embedded in resource,it would be avaliable via https://localhost/_content/RCL/rclimage.png by default.

    You could configure as below in your RCL project if you want it be avaliable via https://localhost/rclimage.png

    <PropertyGroup> 
     <StaticWebAssetBasePath Condition="$(StaticWebAssetBasePath) == ''">/</StaticWebAssetBasePath>
    </PropertyGroup>