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

How to host blazor webassembly app with different base path

$
0
0

I have a Blazor Webassembly, .NET hosted application. On the server we host it on, the base path of the app will be mydomain.com/coolapp. Therefore, to try to get the app to render correctly on the server, I've been following Microsofts steps outlined in the "App base path" section of this page: https://learn.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/?view=aspnetcore-6.0&tabs=visual-studio#app-base-path

I'm following all the steps as I see there, but when I try to run the application, I'm getting 404's from blazor framework files. As far as I can tell, I'm doing everything described in the docs.

  1. Create New blazor wasm project, .net core hosted option checked
  2. Change the base tag in index.html to: <base href="/coolapp/" />
  3. Add this line to Program.cs: app.UsePathBase("/coolapp");
  4. Add app.UseStaticFiles("/coolapp"); //without this, you get 404's from blazor.framework.js and nothing loads
  5. Set launch options for command line argument "commandLineArgs": "--pathbase=/coolapp", in the "BlazorApp1.Server" profile

From there, running the app seems to work in that it finds the required .js files to get started, but then it fails to load the DLLs to run the app, returning all 404s:

enter image description here

If I navigate to this path directly it 404s, but if I remove the /coolapp from the url of the dll, it will download the file. So it's like it's still being hosted to the base path of / rather than /coolapp.

What am I missing? I'm trying the most basic example possible. I pushed my code here for examination: https://github.com/DrLeh/BlazorAppNewBasePath

Companion dotnet git issue: https://github.com/dotnet/aspnetcore/issues/40205


Viewing all articles
Browse latest Browse all 4839

Trending Articles



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