-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Components
Description
Background and Motivation
We've enabled websocket compression on interactive server components in Blazor web. As part of that, we needed new public APIs to configure some of the settings and disable them if needed.
Compression is enabled by default and we don't expect the majority of our customers to change any of the settings.
Proposed API
+ namespace Microsoft.AspNetCore.Components.Server;
+ public class ServerComponentsEndpointOptions()
{
+ public Func<HttpContext!, WebSocketAcceptContext!>? ConfigureWebsocketOptions { get; set; }
+ public ContentSecurityFrameAncestorPolicy { get; set; }
}
+ name Microsoft.AspNetCore.Builder;
+static class ServerRazorComponentsEndpointConventionBuilderExtensions
{
+ RazorComponentsEndpointConventionBuilder .AddInteractiveServerRenderMode(this RazorComponentsEndpointConventionBuilder! builder, Action<ServerComponentsEndpointOptions!>? callback = null)
Usage Examples
Disable compression
builder.MapRazorComponents<App>().AddServerRenderMode(o => o.ConfigureWebSocketOptions = null)
Configure a more strict frame-ancestors directive policy.
builder.MapRazorComponents<App>().AddServerRenderMode(o => o.ContentSecurityFrameAncestorsPolicy = "'none'")
Alternative Designs
Disable compression
We discarded this approach because we still want to support configuring the parameters for the websocket, and we don't want to introduce two settings (CompressionEnabled and the callback). And given that this is going to be extremely rare, the callback we think is good enough.
builder.MapRazorComponents<App>().AddServerRenderMode(o => o.CompressionEnabled = false)
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Components