Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions aspnetcore/blazor/host-and-deploy/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ In other hosting scenarios, such as GitHub Pages and IIS sub-apps, the app base

```csharp
app.UsePathBase("/CoolApp");
// ...
app.UseRouting();
```

* In a Blazor Server app, use ***either*** of the following approaches:
Expand All @@ -124,6 +126,8 @@ In other hosting scenarios, such as GitHub Pages and IIS sub-apps, the app base

```csharp
app.UsePathBase("/CoolApp");
// ...
app.UseRouting();
```

Calling <xref:Microsoft.AspNetCore.Builder.UsePathBaseExtensions.UsePathBase%2A> is recommended when you also wish to run the Blazor Server app locally. For example, supply the launch URL in `Properties/launchSettings.json`:
Expand All @@ -146,6 +150,9 @@ In other hosting scenarios, such as GitHub Pages and IIS sub-apps, the app base
}
```

> [!NOTE]
> When using <xref:Microsoft.AspNetCore.Builder.WebApplication> (see <xref:migration/50-to-60#new-hosting-model>), [`app.UseRouting`](xref:Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions.UseRouting%2A) must be called after `UsePathBase` so that the routing middleware can observe the modified path before matching routes. Otherwise, routes are matched before the path is rewritten by `UsePathBase` as described in the [Middleware Ordering](xref:fundamentals/middleware/index#order) and [Routing](xref:fundamentals/routing) articles.

Do ***not*** prefix links throughout the app with a forward slash. Either avoid the use of a path segment separator or use dot-slash (`./`) relative path notation:

* ❌ Incorrect: `<a href="/account">`
Expand Down
5 changes: 5 additions & 0 deletions aspnetcore/host-and-deploy/proxy-load-balancer.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,13 @@ If `/foo` is the app base path for a proxy path passed as `/foo/api/1`, the midd

```csharp
app.UsePathBase("/foo");
// ...
app.UseRouting();
```

> [!NOTE]
> When using <xref:Microsoft.AspNetCore.Builder.WebApplication> (see <xref:migration/50-to-60#new-hosting-model>), [`app.UseRouting`](xref:Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions.UseRouting%2A) must be called after `UsePathBase` so that the routing middleware can observe the modified path before matching routes. Otherwise, routes are matched before the path is rewritten by `UsePathBase` as described in the [Middleware Ordering](xref:fundamentals/middleware/index#order) and [Routing](xref:fundamentals/routing) articles.

The original path and path base are reapplied when the middleware is called again in reverse. For more information on middleware order processing, see <xref:fundamentals/middleware/index>.

If the proxy trims the path (for example, forwarding `/foo/api/1` to `/api/1`), fix redirects and links by setting the request's [PathBase](xref:Microsoft.AspNetCore.Http.HttpRequest.PathBase) property:
Expand Down