diff --git a/Moonlight/Core/Configuration/CoreConfiguration.cs b/Moonlight/Core/Configuration/CoreConfiguration.cs index 07ba758..6af7336 100644 --- a/Moonlight/Core/Configuration/CoreConfiguration.cs +++ b/Moonlight/Core/Configuration/CoreConfiguration.cs @@ -39,6 +39,15 @@ public class CoreConfiguration [Description("Specifies the location of the key .pem file to load")] [JsonProperty("KeyPath")] public string KeyPath { get; set; } = ""; + + [Description("Specifies the file upload limit per http request in megabytes")] + [JsonProperty("UploadLimit")] + public int UploadLimit { get; set; } = 100; + + [Description( + "Specifies the maximum message size moonlight can receive via the websocket connection in kilobytes")] + [JsonProperty("MessageSizeLimit")] + public int MessageSizeLimit { get; set; } = 1024; } public class DatabaseData diff --git a/Moonlight/Core/CoreFeature.cs b/Moonlight/Core/CoreFeature.cs index a2d8a63..f8513fa 100644 --- a/Moonlight/Core/CoreFeature.cs +++ b/Moonlight/Core/CoreFeature.cs @@ -64,15 +64,26 @@ public class CoreFeature : MoonlightFeature // Add external services and blazor/asp.net stuff builder.Services.AddRazorPages(); - builder.Services.AddServerSideBlazor(); builder.Services.AddHttpContextAccessor(); builder.Services.AddControllers(); builder.Services.AddBlazorTable(); + + // Configure blazor pipeline in detail + builder.Services.AddServerSideBlazor().AddHubOptions(options => + { + options.MaximumReceiveMessageSize = ByteSizeValue.FromKiloBytes(config.Http.MessageSizeLimit).Bytes; + }); // Setup authentication if required if (config.Authentication.UseDefaultAuthentication) builder.Services.AddScoped(); + // Setup http upload limit + context.Builder.WebHost.ConfigureKestrel(options => + { + options.Limits.MaxRequestBodySize = ByteSizeValue.FromMegaBytes(config.Http.UploadLimit).Bytes; + }); + // Assets // - Javascript