Background and Motivation
Users of AddInteractiveServerRenderMode had no clean way to configure the underlying SignalR HttpConnectionDispatcherOptions. Previously, users had to resort to workarounds using metadata inspection to access properties like CloseOnAuthenticationExpiration. The old MapBlazorHub had overloads accepting dispatcher options, but AddInteractiveServerRenderMode did not expose this configuration surface.
Source: PR #63825, fixes #63520.
Proposed API
namespace Microsoft.AspNetCore.Components.Server;
public class ServerComponentsEndpointOptions
{
+ public Action<HttpConnectionDispatcherOptions>? ConfigureConnection { get; set; }
}
Usage Examples
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode(options =>
{
options.ConfigureConnection = dispatcherOptions =>
{
dispatcherOptions.CloseOnAuthenticationExpiration = true;
dispatcherOptions.AllowStatefulReconnects = true;
dispatcherOptions.ApplicationMaxBufferSize = 1024 * 1024;
};
});
Alternative Designs
The workaround was inspecting metadata via .Add(e => { var opts = e.Metadata.OfType<HttpConnectionDispatcherOptions>().FirstOrDefault(); ... }). This was not type-safe, hard to discover, fragile, and inconsistent with MapBlazorHub.
Risks
None — additive property, null by default preserves existing behavior. Zero overhead when not used.
Background and Motivation
Users of
AddInteractiveServerRenderModehad no clean way to configure the underlying SignalRHttpConnectionDispatcherOptions. Previously, users had to resort to workarounds using metadata inspection to access properties likeCloseOnAuthenticationExpiration. The oldMapBlazorHubhad overloads accepting dispatcher options, butAddInteractiveServerRenderModedid not expose this configuration surface.Source: PR #63825, fixes #63520.
Proposed API
namespace Microsoft.AspNetCore.Components.Server; public class ServerComponentsEndpointOptions { + public Action<HttpConnectionDispatcherOptions>? ConfigureConnection { get; set; } }Usage Examples
Alternative Designs
The workaround was inspecting metadata via
.Add(e => { var opts = e.Metadata.OfType<HttpConnectionDispatcherOptions>().FirstOrDefault(); ... }). This was not type-safe, hard to discover, fragile, and inconsistent withMapBlazorHub.Risks
None — additive property, null by default preserves existing behavior. Zero overhead when not used.