From c4e9a5abb847164a1b60059c13d4275b4132e88c Mon Sep 17 00:00:00 2001 From: SQL-MisterMagoo Date: Wed, 24 Dec 2025 00:03:40 +0000 Subject: [PATCH 1/2] Revise SignalR hub path and base path configuration Updated SignalR hub mapping and base path instructions for server-side Blazor applications. Based on efforts trying to get this to work in .NET 10, the existing documentation does not work. `MapBlazorHub` only appears to work when the path ends with `_blazor` The code sample for a branched middleware pipeline was incomplete - this change appears to be the minimal implementation to get things working. `UsePathBase` does not negate the need to set `` but the previous docs stated to use **either** not **both** as seems to be required. --- .../blazor/host-and-deploy/app-base-path.md | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/aspnetcore/blazor/host-and-deploy/app-base-path.md b/aspnetcore/blazor/host-and-deploy/app-base-path.md index b2f754d0e0e4..fe7002884799 100644 --- a/aspnetcore/blazor/host-and-deploy/app-base-path.md +++ b/aspnetcore/blazor/host-and-deploy/app-base-path.md @@ -79,7 +79,7 @@ For the second option, which is the usual approach taken, the app sets the base Map the SignalR hub of a server-side Blazor app by passing the path to in the `Program` file: ```csharp -app.MapBlazorHub("base/path"); +app.MapBlazorHub("base/path/_blazor"); ``` The benefit of using is that you can map patterns, such as `"{tenant}"` and not just concrete paths. @@ -87,13 +87,22 @@ The benefit of using { - subapp.UsePathBase("/base/path/"); +app.Map("/base/path", subapp => { + subapp.UsePathBase("/base/path"); subapp.UseRouting(); - subapp.UseEndpoints(endpoints => endpoints.MapBlazorHub()); + subapp.UseAntiforgery(); + subapp.UseEndpoints(endpoints => { + endpoints.MapBlazorHub("/base/path/_blazor"); + endpoints.MapStaticAssets(); + endpoints.MapRazorComponents() + .AddInteractiveServerRenderMode(); + }); }); ``` +> [!NOTE] +> The default path to a Blazor hub is `_blazor` and so your mapped path must end with `/_blazor` + Configure the `` tag, per the guidance in the [Configure the app base path](#configure-the-app-base-path) section. :::moniker range="< aspnetcore-8.0" @@ -144,9 +153,9 @@ In many hosting scenarios, the relative URL path to the app is the root of the a > [!NOTE] > In some hosting scenarios, such as GitHub Pages and IIS sub-apps, the app base path must be set to the server's relative URL path of the app. -* In a server-side Blazor app, use ***either*** of the following approaches: +* In a server-side Blazor app, use the following approach: - * Option 1: Use the `` tag to set the app's base path ([location of `` content](xref:blazor/project-structure#location-of-head-and-body-content)): + * Use the `` tag to set the app's base path ([location of `` content](xref:blazor/project-structure#location-of-head-and-body-content)): ```html @@ -154,7 +163,7 @@ In many hosting scenarios, the relative URL path to the app is the root of the a **The trailing slash is required.** - * Option 2: Call ***first*** in the app's request processing pipeline (`Program.cs`) immediately after the is built (`builder.Build()`) to configure the base path for any following middleware that interacts with the request path: + * Call ***first*** in the app's request processing pipeline (`Program.cs`) immediately after the is built (`builder.Build()`) to configure the base path for any following middleware that interacts with the request path: ```csharp app.UsePathBase("/CoolApp"); From 72d3ec17069ec9940dce98bbad8ec1e2be04320f Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Mon, 5 Jan 2026 07:05:24 -0500 Subject: [PATCH 2/2] Apply suggestions from code review --- aspnetcore/blazor/host-and-deploy/app-base-path.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aspnetcore/blazor/host-and-deploy/app-base-path.md b/aspnetcore/blazor/host-and-deploy/app-base-path.md index fe7002884799..440b9c4557e7 100644 --- a/aspnetcore/blazor/host-and-deploy/app-base-path.md +++ b/aspnetcore/blazor/host-and-deploy/app-base-path.md @@ -76,7 +76,7 @@ For the second option, which is the usual approach taken, the app sets the base ## Server-side Blazor -Map the SignalR hub of a server-side Blazor app by passing the path to in the `Program` file: +Map the SignalR hub of a server-side Blazor app by passing the path to in the `Program` file. The default Blazor hub path is `/_blazor`, and the following example sets the base path of the default hub to `base/path`: ```csharp app.MapBlazorHub("base/path/_blazor"); @@ -101,7 +101,7 @@ app.Map("/base/path", subapp => { ``` > [!NOTE] -> The default path to a Blazor hub is `_blazor` and so your mapped path must end with `/_blazor` +> The default Blazor hub path is `/_blazor`. Configure the `` tag, per the guidance in the [Configure the app base path](#configure-the-app-base-path) section.