-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Comments
Thanks for contacting us. |
Hello @DrLeh ... I work on the Blazor docs and have 👀 on your issue/discussion here. We've had our share of successes and failures trying to cover the app base path scenarios with that guidance. Some readers have reported it works perfectly, others ... as in this case ... have trouble with it. We usually sort out the situation and make further updates to the content. I'll take a look at your posted repro as soon as I can, but I'm 🏃 on a few high priority issues at the moment. I hope to be free on Thursday. UPDATE: Ran one day late. I'll take a look at the repro tomorrow, Friday. |
@DrLeh ... I didn't get too deep into your repro sample before noticing that your call to This is per our current middleware guidance, but it isn't cross-linked directly to the Blazor App base path section, which I think we'll need to do ... even if it doesn't resolve some or all of the foul routing behavior with your app.
Cross-reference: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-6.0#aspnet-core-endpoint-definition |
@guardrex that seems to have helped. I put it near the top, before the |
I see. I can't explain that behavior. I do think that it makes sense for the Blazor App base path section to recommend the setting early in the request processing pipeline ... first is where I normally place it. I'll open an issue to address that aspect and remain 👂 here for further discussion. |
@mkArtakMSFT ... I made a doc update to prompt devs to place a call to |
Thanks @guardrex. |
Is there an existing issue for this?
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-pathI'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
index.html
to:<base href="/coolapp/" />
Program.cs
:app.UsePathBase("/coolapp");
app.UseStaticFiles("/coolapp"); //without this, you get 404's from blazor.framework.js and nothing loads
"commandLineArgs": "--pathbase=/coolapp",
in the"BlazorApp1.Server"
profilelocalhost:port/coolapp
pathFrom 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.
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
The text was updated successfully, but these errors were encountered: