Open Closed

Error when Launching Blazor WASM #9695


User avatar
0
Spospisil created

Hi,

I am getting the below error when I am launching my Blazor WASM application. I believe it's happening because the app.MapAbpStaticAssets is trying to retrieve my appsettings.json file from the Virtural File System, but I always want it to be served from wwwroot. Part of what complicates this is we want our application to be serviced from a subfolder of "/Blazor", so we are using the app.UsePathBase method.

At runtime we dynamically populate the appsettings.json file with configurable values from our container environment which is why I need the above functionality. Based on another ticket (https://abp.io/support/questions/9666/Fontawesome-Icons-Not-Showing#answer-3a1b6d7e-4e0e-c8aa-30c8-249d1caa71f8) I believe this is why my font awesome icons are not showing so if I can resolve this issue I think it'll resolve my other issue.

I've created a github repo with a sample project created with ABP Studio and the code to reproduce the issue. If you can examine the code in the TestWasmBlazorModule and tell me if I have it correct in order to do what I detailed above that would be helpful.

I've shared access to this repo with maliming


4 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent

    To ensure your Blazor WASM app always serves appsettings.json from wwwroot (not from the ABP Virtual File System), especially when using app.UsePathBase for a subfolder (e.g., "/Blazor"), follow these steps:

    1. Place your appsettings.json in the wwwroot folder of your host project (not in the virtual file system or embedded resources).
    2. Make sure you do NOT register appsettings.json as an embedded resource or virtual file in your project or any ABP module.
    3. In your Program.cs or Startup, after app.UsePathBase("/Blazor"), ensure you have:
    app.UseStaticFiles(); // This serves files from wwwroot, including appsettings.json
       app.MapAbpStaticAssets(); // This serves ABP static/virtual files
    

    The order is important: UseStaticFiles should come before MapAbpStaticAssets.

    1. When fetching appsettings.json in your Blazor WASM client, use a relative path that respects the base path:
    fetch('./appsettings.json')
    

    or, if you use a base tag in your index.html:

    <base href="/Blazor/">
    

    then

    fetch('appsettings.json')
    
    1. If you dynamically generate appsettings.json at runtime, ensure your deployment process writes it to wwwroot before the app starts.

    2. If you use a subfolder (path base), make sure all static file requests (including appsettings.json and font files) are prefixed with the base path.

    3. If you see JSON parsing errors, verify that the appsettings.json file is present, accessible, and contains valid JSON. A 404 or empty file will cause the error you see.

    This approach ensures your appsettings.json is always served from wwwroot, not from the virtual file system, and works with dynamic updates and subfolder hosting.

    Sources:


    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Solution: https://abp.io/support/questions/9666/Fontawesome-Icons-Not-Showing?CurrentPage=2#answer-3a1b72d9-4f78-be18-45bd-1f3a827ec332

  • User Avatar
    0
    Spospisil created

    Not really a solution more of a workaround. The solution would be to make these links recognize the UsePathBase value. I see this as an ABP bug.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Move to https://abp.io/support/questions/9666/Fontawesome-Icons-Not-Showing?CurrentPage=2#answer-3a1b755f-59b7-7606-24b0-91c8a8cdcace

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on August 28, 2025, 08:29