using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.Extensions.Options; using Umbraco.Cms.Core.Configuration.Models; namespace Umbraco.Cms.Web.Common.Security { public class ConfigureKestrelServerOptions : IConfigureOptions { private readonly IOptions _runtimeSettings; public ConfigureKestrelServerOptions(IOptions runtimeSettings) => _runtimeSettings = runtimeSettings; public void Configure(KestrelServerOptions options) { // convert from KB to bytes options.Limits.MaxRequestBodySize = _runtimeSettings.Value.MaxRequestLength.HasValue ? _runtimeSettings.Value.MaxRequestLength.Value * 1024 : long.MaxValue; } } }