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

Blazor Hosted WebAssembly subpath (base-href) not working with some nuget packages

$
0
0

I have a Blazor Hosted WebAssembly which means that I have three projects, the Client, the Server and the Shared. The inter-communication happens with web-apis.

On the Client, into index.html I have the following:

<base href="/app/" />

On the Client, into Clientn.csproj I have the following:

<StaticWebAssetBasePath>app</StaticWebAssetBasePath>

On the Server, into program.cs I have the following:

app.UseBlazorFrameworkFiles("/app");app.UseStaticFiles();app.UsePathBase("/app");app.MapFallbackToFile("/app" +"/" +"index.html");

With those settings the application starts and loading but it fails to load packages:

Blazored.ModalBlazored.TextEditorMicrosoft.AspNetCore.Components.WebAssembly.Authentication

These packages are trying to find resources into /app/_content but the resources are not there.enter image description here

enter image description here

When we use the following code in the Program.cs file of the Server

app.UseStaticFiles("/app"); //instead of app.UseStaticFiles();

Then the packages are resolved under app/_content but css and js files refferenced into index.html are not resolved

<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" /><link href="css/toggle-switch/toggle-switch.css" rel="stylesheet" /><link href="css/parameters.css" rel="stylesheet" /><link href="css/app.css" rel="stylesheet" /><script src="js/jquery-3.5.1.slim.min.js"></script><script src="js/popper.min.js"></script><script src="js/bootstrap.min.js"></script><script src="js/listener.js"></script><script src="js/function.js"></script><script src="js/events.js"></script><script src="js/files.js"></script><script src="js/tab.js"></script>

When the application is running without a subpath it works normallyenter image description here

Any ideas?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



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