2

When deployed .net core hosted Blazor app is served from myserver.com/myapp.

I've set <base href="/myapp/" /> in index.html and it works when published.

To avoid changing it all the time manually I tried to follow official documentation on Path Base and to add:

  1. "commandLineArgs": "--pathbase=/myapp" or
  2. "commandLineArgs": "--pathbase=/" even
  3. "commandLineArgs": "--pathbase="

in launchSettings.json.

I've tried putting it in all configuration profiles but for some reason it does not work when debugging. It can't find resources.

I've also tried running from console: dotnet run --pathbase=/myapp but no luck.

EDIT: --pathbase=/myapp works for stand alone Blazor apps, but not for ASP.NET Core hosted one. At least not out of the box.

Is there a way to pass this config from "Server" to "Client" or to tell to the "Client" to use it in debug mode?

Milan
  • 969
  • 2
  • 16
  • 34
  • I am having the same issue :( I have tried passing it to the aspnetcore project that is hosting the blazor client but it simply says: Unknown option: --pathbase=/Prod – Matthew Joughin May 15 '21 at 06:22
  • Why are you setting the path manually? Why can't you use [the `ContentRoot` as set in the `HostEnvironment` 'automatically'](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/host/generic-host?view=aspnetcore-5.0#contentroot) – JHBonarius May 15 '21 at 06:47
  • I'm having a similar issue: https://stackoverflow.com/questions/71113666/how-to-host-blazor-webassembly-app-with-different-base-path – DLeh Feb 14 '22 at 15:16

1 Answers1

2

I had the same issue and my solution was to set the following

In index.html

<base href="/myapp/" />

In launchSettings.json

"commandLineArgs": "--pathbase=/myapp",
"launchUrl": "myapp",
  • Can you provide a complete 'launchsettings.json'. The one I have (that VS uses) has multiple sections. Which one will IIS use? – Neil Mar 03 '23 at 12:11