Add BlazorServerOptions for SignalR message size config
Introduced a new `BlazorServerOptions` class to manage Blazor Server runtime configuration. Added support for configuring the maximum SignalR message size via `appsettings.json` under the `BlazorServer` section. Updated `Program.cs` to apply this configuration to SignalR hub options and register `BlazorServerOptions` with the DI container.
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
namespace EnvelopeGenerator.Server.Options;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Configuration options for Blazor Server runtime behavior.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class BlazorServerOptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Configuration section name in appsettings.json.
|
||||||
|
/// </summary>
|
||||||
|
public const string SectionName = "BlazorServer";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Maximum incoming SignalR message size (in bytes) for interactive server circuits.
|
||||||
|
/// If null, framework default is used.
|
||||||
|
/// </summary>
|
||||||
|
public long? MaximumReceiveMessageSize { get; set; }
|
||||||
|
}
|
||||||
@@ -55,9 +55,16 @@ try
|
|||||||
|
|
||||||
var deferredProvider = new DeferredServiceProvider();
|
var deferredProvider = new DeferredServiceProvider();
|
||||||
|
|
||||||
|
var blazorServerOptions = config.GetSection(BlazorServerOptions.SectionName)
|
||||||
|
.Get<BlazorServerOptions>() ?? new BlazorServerOptions();
|
||||||
|
|
||||||
// Add Blazor services
|
// Add Blazor services
|
||||||
builder.Services.AddRazorComponents()
|
builder.Services.AddRazorComponents()
|
||||||
.AddInteractiveServerComponents()
|
.AddInteractiveServerComponents()
|
||||||
|
.AddHubOptions(options =>
|
||||||
|
{
|
||||||
|
options.MaximumReceiveMessageSize = blazorServerOptions.MaximumReceiveMessageSize;
|
||||||
|
})
|
||||||
.AddInteractiveWebAssemblyComponents();
|
.AddInteractiveWebAssemblyComponents();
|
||||||
builder.Services.AddMudServices();
|
builder.Services.AddMudServices();
|
||||||
|
|
||||||
@@ -294,6 +301,7 @@ try
|
|||||||
builder.Services.AddCookieBasedLocalizer();
|
builder.Services.AddCookieBasedLocalizer();
|
||||||
|
|
||||||
// Cache options
|
// Cache options
|
||||||
|
builder.Services.Configure<BlazorServerOptions>(config.GetSection(BlazorServerOptions.SectionName));
|
||||||
builder.Services.Configure<CacheOptions>(config.GetSection(CacheOptions.SectionName));
|
builder.Services.Configure<CacheOptions>(config.GetSection(CacheOptions.SectionName));
|
||||||
builder.Services.Configure<SenderFeatureAccessOptions>(config.GetSection(SenderFeatureAccessOptions.SectionName));
|
builder.Services.Configure<SenderFeatureAccessOptions>(config.GetSection(SenderFeatureAccessOptions.SectionName));
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,9 @@
|
|||||||
"MainCanvasEnableHiDPI": true,
|
"MainCanvasEnableHiDPI": true,
|
||||||
"ZoomStepPercentage": 5
|
"ZoomStepPercentage": 5
|
||||||
},
|
},
|
||||||
|
"BlazorServer": {
|
||||||
|
"MaximumReceiveMessageSize": 2097152
|
||||||
|
},
|
||||||
"SignatureFieldParams": {
|
"SignatureFieldParams": {
|
||||||
"Width": 1.77,
|
"Width": 1.77,
|
||||||
"Height": 1.96
|
"Height": 1.96
|
||||||
|
|||||||
Reference in New Issue
Block a user