The Wayback Machine - https://web.archive.org/web/20220214145844/https://github.com/dotnet/aspnetcore/issues/40205
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Host blazor webassembly app with different base path is not working as described in documentation #40205

Open
1 task done
DrLeh opened this issue Feb 14, 2022 · 0 comments
Open
1 task done

Comments

@DrLeh
Copy link

@DrLeh DrLeh commented Feb 14, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

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://docs.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.

Expected Behavior

Following the steps as outlined in documentation should allow me to run my app locally, despite being configured to run at the /coolapp path when hosted on another server. Instead I get 404's from key files that are still hosted at the wrong path. Documentation is unclear whether I'm missing something.

Steps To Reproduce

  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
  6. Run application

From there, the app shows "An unhandled error has occurred. Reload" link, indicating that it has loaded some javascript. Inspecting the network tab in dev tools shows that the .dll files are 404ing.

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

Exceptions (if any)

No response

.NET Version

6.0.101

Anything else?

Companion SO question: https://stackoverflow.com/questions/71113666/how-to-host-blazor-webassembly-app-with-different-base-path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant