diff --git a/aspnetcore/blazor/host-and-deploy/app-base-path.md b/aspnetcore/blazor/host-and-deploy/app-base-path.md index b2f754d0e0e4..440b9c4557e7 100644 --- a/aspnetcore/blazor/host-and-deploy/app-base-path.md +++ b/aspnetcore/blazor/host-and-deploy/app-base-path.md @@ -76,10 +76,10 @@ 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"); +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 Blazor hub path is `/_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");