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.
- Create New blazor wasm project, .net core hosted option checked
- Change the base tag in
index.html
to:<base href="/coolapp/" />
- Add this line to
Program.cs
:app.UsePathBase("/coolapp");
- Add
app.UseStaticFiles("/coolapp"); //without this, you get 404's from blazor.framework.js and nothing loads
- 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:
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