I recently upgraded my application from .NET 7 to .NET 8 and am facing an issue related to the base tag, which was previously used in _Host.cshtml with the tag helper syntax: <base href="~/" />. This setup worked well, accommodating both development and production environments:
Development: The app ran on https://localhost:port.
Production: After publishing to an IIS site, the app was available under https://server/app.
In .NET 8 Blazor Web, project structure has changed, so I also want to use App.razor. However, I'm encountering issues when setting the <base href="/app/" /> as per the migration docs. Unlike the tag helper in the previous version, this approach uses a static value. Additionally, I'm facing a case-sensitivity issue where navigating to https://server/App (note the uppercase 'A') results in a 404 error.
How can I replicate the dynamic base URL behaviour from .NET 7's _Host.cshtml in the new .NET 8 App.razor model to ensure my application works seamlessly in both development and production environments?
I have read:
- https://learn.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/?view=aspnetcore-8.0&tabs=visual-studio
- Override the base path for production only in a Blazor Web App (_Hosts.cshtml file functionality in .NET 8?)
- https://learn.microsoft.com/en-us/aspnet/core/migration/70-80?view=aspnetcore-8.0&tabs=visual-studio#convert-a-blazor-server-app-into-a-blazor-web-app
I have tried using app.UsePathBase("/app"); without any success.