Skip to content

Commit f166698

Browse files
authored
Merge pull request #36018 from dotnet/main
2 parents cd97cfe + 527cfb0 commit f166698

File tree

13 files changed

+429
-28
lines changed

13 files changed

+429
-28
lines changed

aspnetcore/blazor/fundamentals/signalr.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,25 +316,43 @@ app.MapBlazorHub(options =>
316316
});
317317
```
318318

319-
<!-- UPDATE 10.0 The following is scheduled for a fix in .NET 10 -->
319+
<!-- UPDATE 10.0 - The following is scheduled for a fix in .NET 10.
320+
Tracked by: https://github.com/dotnet/aspnetcore/issues/63520 -->
320321

321-
Configuring the hub used by <xref:Microsoft.AspNetCore.Builder.ServerRazorComponentsEndpointConventionBuilderExtensions.AddInteractiveServerRenderMode%2A> with <xref:Microsoft.AspNetCore.Builder.ComponentEndpointRouteBuilderExtensions.MapBlazorHub%2A> fails with an `AmbiguousMatchException`:
322+
Configuring the hub used by <xref:Microsoft.AspNetCore.Builder.ServerRazorComponentsEndpointConventionBuilderExtensions.AddInteractiveServerRenderMode%2A> with <xref:Microsoft.AspNetCore.Builder.ComponentEndpointRouteBuilderExtensions.MapBlazorHub%2A> fails with an <xref:System.Reflection.AmbiguousMatchException>:
322323

323324
> :::no-loc text="Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched multiple endpoints.":::
324325
325-
To workaround the problem for apps targeting .NET 8, give the custom-configured Blazor hub higher precedence using the <xref:Microsoft.AspNetCore.Builder.RoutingEndpointConventionBuilderExtensions.WithOrder%2A> method:
326+
To workaround the problem for apps targeting .NET 8/9, take the following approach.
327+
328+
At the top of the `Program` file, add a `using` statement for <xref:Microsoft.AspNetCore.Http.Connections?displayProperty=fullName>:
326329

327330
```csharp
328-
app.MapBlazorHub(options =>
329-
{
330-
options.CloseOnAuthenticationExpiration = true;
331-
}).WithOrder(-1);
331+
using Microsoft.AspNetCore.Http.Connections;
332+
```
333+
334+
Where <xref:Microsoft.AspNetCore.Builder.RazorComponentsEndpointRouteBuilderExtensions.MapRazorComponents%2A> is called, chain the following endpoint convention to the <xref:Microsoft.AspNetCore.Builder.RazorComponentsEndpointConventionBuilder>:
335+
336+
```csharp
337+
app.MapRazorComponents<App>()
338+
.AddInteractiveServerRenderMode()
339+
.Add(e =>
340+
{
341+
var metadata = e.Metadata;
342+
var dispatcherOptions = metadata.OfType<HttpConnectionDispatcherOptions>().FirstOrDefault();
343+
344+
if (dispatcherOptions != null)
345+
{
346+
dispatcherOptions.CloseOnAuthenticationExpiration = true;
347+
}
348+
});
332349
```
333350

334351
For more information, see the following resources:
335352

336353
* [MapBlazorHub configuration in NET8 throws a The request matched multiple endpoints exception (`dotnet/aspnetcore` #51698)](https://github.com/dotnet/aspnetcore/issues/51698#issuecomment-1984340954)
337354
* [Attempts to map multiple blazor entry points with MapBlazorHub causes Ambiguous Route Error. This worked with net7 (`dotnet/aspnetcore` #52156)](https://github.com/dotnet/aspnetcore/issues/52156#issuecomment-1984503178)
355+
* [[Blazor] Provide access to the underlying SignalR HttpConnectionDispatcherOptions in AddInteractiveServerRenderMode (`dotnet/aspnetcore` #63520)](https://github.com/dotnet/aspnetcore/issues/63520)
338356

339357
:::moniker-end
340358

aspnetcore/blazor/security/includes/redirecttologin-component.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,29 @@ The `RedirectToLogin` component (`RedirectToLogin.razor`):
77

88
Inspect the `RedirectToLogin` component in [reference source](https://github.com/dotnet/aspnetcore/tree/main/src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp). The location of the component changed over time, so use GitHub search tools to locate the component.
99

10+
The login path can be customized by the app (<xref:Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationApplicationPathsOptions.LogInPath%2A?displayProperty=nameWithType>, [framework defaults (`dotnet/aspnetcore` reference source)](https://github.com/dotnet/aspnetcore/blob/main/src/Components/WebAssembly/WebAssembly.Authentication/src/RemoteAuthenticationDefaults.cs)). The project template's `RedirectToLogin` component uses the default login path of `authentication/login`.
11+
1012
[!INCLUDE[](~/includes/aspnetcore-repo-ref-source-links.md)]
13+
14+
If an app [customizes the login path](xref:blazor/security/webassembly/additional-scenarios#customize-app-routes), take either of the following approaches:
15+
16+
* Match the path in the hard-coded string in the `RedirectToLogin` component.
17+
* Inject <xref:Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions> to obtain the configured value. For example, take this approach when you customize the path with <xref:Microsoft.Extensions.DependencyInjection.WebAssemblyAuthenticationServiceCollectionExtensions.AddApiAuthorization%2A>.
18+
Add the following directives at the top of the `RedirectToLogin` component:
19+
20+
```razor
21+
@using Microsoft.Extensions.Options
22+
@inject IOptionsSnapshot<RemoteAuthenticationOptions<ApiAuthorizationProviderOptions>> RemoteOptions
23+
```
24+
25+
Modify the component's redirect in the `OnInitialized` method:
26+
27+
```diff
28+
- Navigation.NavigateToLogin("authentication/login");
29+
+ Navigation.NavigateToLogin(RemoteOptions.Get(Options.DefaultName)
30+
+ .AuthenticationPaths.LogInPath);
31+
```
32+
33+
> [!NOTE]
34+
> If other paths differ from the project template's paths or [framework's default paths](https://github.com/dotnet/aspnetcore/blob/main/src/Components/WebAssembly/WebAssembly.Authentication/src/RemoteAuthenticationDefaults.cs), they should managed in the same fashion.
35+

aspnetcore/fundamentals/error-handling.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ uid: fundamentals/error-handling
1212

1313
[!INCLUDE[](~/includes/not-latest-version.md)]
1414

15-
:::moniker range=">= aspnetcore-9.0"
15+
:::moniker range=">= aspnetcore-10.0"
1616

1717
This article covers common approaches to handling errors in ASP.NET Core web apps. See also <xref:fundamentals/error-handling-api>.
1818

@@ -343,8 +343,10 @@ An alternative approach to generate problem details is to use the third-party Nu
343343
* <xref:test/troubleshoot-azure-iis>
344344
* <xref:host-and-deploy/azure-iis-errors-reference>
345345
* <xref:fundamentals/error-handling-api>
346+
* [Breaking change: Exception diagnostics are suppressed when `IExceptionHandler.TryHandleAsync` returns true](https://github.com/aspnet/Announcements/issues/524)
346347

347348
:::moniker-end
348349

350+
[!INCLUDE[](~/fundamentals/error-handling/includes/error-handling9.md)]
349351
[!INCLUDE[](~/fundamentals/error-handling/includes/error-handling8.md)]
350352
[!INCLUDE[](~/fundamentals/error-handling/includes/error-handling3-7.md)]

0 commit comments

Comments
 (0)