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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Connections;

namespace Microsoft.AspNetCore.Components.Server;

Expand Down Expand Up @@ -53,4 +54,13 @@ public class ServerComponentsEndpointOptions
/// defined in <see cref="ContentSecurityFrameAncestorsPolicy"/> will be applied.
/// </remarks>
public Func<HttpContext, WebSocketAcceptContext, Task>? ConfigureWebSocketAcceptContext { get; set; }

/// <summary>
/// Gets or sets a callback to configure the <see cref="HttpConnectionDispatcherOptions"/> used by the SignalR connection.
/// </summary>
/// <remarks>
/// This allows configuring options such as <see cref="HttpConnectionDispatcherOptions.CloseOnAuthenticationExpiration"/>,
/// transport options, authorization data, and other connection-level settings.
/// </remarks>
public Action<HttpConnectionDispatcherOptions>? ConfigureConnection { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ public override IEnumerable<RouteEndpointBuilder> GetEndpointBuilders(
}

var endpointRouteBuilder = new EndpointRouteBuilder(Services, applicationBuilder);
var hub = endpointRouteBuilder.MapBlazorHub("/_blazor");
var serverRenderMode = (InternalServerRenderMode)renderMode;
var hub = serverRenderMode.Options?.ConfigureConnection is not null
? endpointRouteBuilder.MapBlazorHub("/_blazor", serverRenderMode.Options.ConfigureConnection)
: endpointRouteBuilder.MapBlazorHub("/_blazor");

if (renderMode is InternalServerRenderMode { Options.ConfigureWebSocketAcceptContext: var configureConnection, Options.DisableWebSocketCompression: var disableCompression } &&
(configureConnection is not null || !disableCompression))
Expand Down
2 changes: 2 additions & 0 deletions src/Components/Server/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
#nullable enable
Microsoft.AspNetCore.Components.Server.ServerComponentsEndpointOptions.ConfigureConnection.get -> System.Action<Microsoft.AspNetCore.Http.Connections.HttpConnectionDispatcherOptions!>?
Microsoft.AspNetCore.Components.Server.ServerComponentsEndpointOptions.ConfigureConnection.set -> void
Loading