Skip to content

UUF: Blazor: Host & Deploy: Server: Clarify trailing slash requirement #36059

@wadepickett

Description

@wadepickett

Description

The following is AI autogenerated from UUF system user feedback triage details.

The proposed problem/solution is just an AI generated suggestion, so treat it as such:

User feedback transferred from UUF System:

"app. UsePathBase("/AppName");When deploying this way, the urlmywebsite.com/App does not load all resoursesmywebsite.com/App/ does"

Problem Statement

The documentation for configuring base paths in server-side Blazor apps does not clearly explain that when using UsePathBase(), a trailing slash is critical for proper resource loading. Specifically, when an app is configured with app.UsePathBase("/AppName"), accessing the app via a URL without a trailing slash (e.g., mywebsite.com/AppName) may fail to load all resources correctly, while accessing it with a trailing slash (e.g., mywebsite.com/AppName/) works properly.

This is a common deployment issue that deserves explicit warning in the documentation.

Proposed Solution

Add a prominent warning note in the "Server-side Blazor" section of the app-base-path.md document that clearly explains:

  1. The importance of the trailing slash in URLs when accessing Blazor Server apps with a configured path base
  2. The difference in behavior between URLs with and without trailing slashes
  3. Potential solutions (URL rewriting, redirects)

Suggested Changes

Add the following warning note to the "Server-side Blazor" section in aspnetcore/blazor/host-and-deploy/app-base-path.md (around line 92, after the code block showing app.Map("/base/path/", subapp => {...):

> [!WARNING]
> When using `UsePathBase` with Blazor Server apps, be aware of the trailing slash requirement in URLs. If you configure your app with `app.UsePathBase("/AppName")`, accessing it via `https://example.com/AppName` (without trailing slash) may not load all resources correctly, while `https://example.com/AppName/` (with trailing slash) will work properly. This is because the browser resolves relative resource URLs differently based on whether the URL has a trailing slash.
> 
> To ensure consistent behavior, consider implementing URL rewriting to add the trailing slash or instructing users to always include the trailing slash when accessing your app.

Page URL

https://learn.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/server/?view=aspnetcore-9.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/host-and-deploy/server/index.md

Document ID

7b8429b0-dbb8-9768-572c-8fa04ec42146

Platform Id

da71d702-4227-7e6c-feb8-df36315ffbe4

Article author

@guardrex

Metadata

  • ID: 7b8429b0-dbb8-9768-572c-8fa04ec42146
  • PlatformId: da71d702-4227-7e6c-feb8-df36315ffbe4
  • Service: aspnet-core
  • Sub-service: blazor

Related Issues

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions