v9: Fix max allowed content length on iis & kestrel (#11802)

* Update web.config

* Change web.config to align with v8 default values

* Adjust kestrel options to align with v8

* Add better comment

* added web.config to root

* change web.config to 30mb

* delete obsolete comment

* No reason to have web.config to just have it default

* Add back ConfigureIISServerOptions.cs

* Add obsolete comment, can't link to documentation yet as it doesn't exist

* Apply suggestions from code review

Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>

* Add link to documentation

Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>
This commit is contained in:
Nikolaj Geisle
2022-01-12 12:32:53 +01:00
committed by GitHub
parent d9bdd8196c
commit 18a3133536
4 changed files with 11 additions and 6 deletions

View File

@@ -109,7 +109,6 @@ namespace Umbraco.Extensions
var appCaches = AppCaches.Create(requestCache);
services.ConfigureOptions<ConfigureKestrelServerOptions>();
services.ConfigureOptions<ConfigureIISServerOptions>();
services.ConfigureOptions<ConfigureFormOptions>();
IProfiler profiler = GetWebProfiler(config);

View File

@@ -1,18 +1,24 @@
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
namespace Umbraco.Cms.Web.Common.Security
{
[Obsolete("This class is obsolete, as this does not configure your Maximum request length, see https://our.umbraco.com/documentation/Reference/V9-Config/MaximumUploadSizeSettings/ for information about configuring maximum request length")]
public class ConfigureIISServerOptions : IConfigureOptions<IISServerOptions>
{
private readonly IOptions<RuntimeSettings> _runtimeSettings;
public ConfigureIISServerOptions(IOptions<RuntimeSettings> runtimeSettings) => _runtimeSettings = runtimeSettings;
public ConfigureIISServerOptions(IOptions<RuntimeSettings> runtimeSettings) =>
_runtimeSettings = runtimeSettings;
public void Configure(IISServerOptions options)
{
// convert from KB to bytes
options.MaxRequestBodySize = _runtimeSettings.Value.MaxRequestLength.HasValue ? _runtimeSettings.Value.MaxRequestLength.Value * 1024 : uint.MaxValue; // ~4GB is the max supported value for IIS and IIS express.
options.MaxRequestBodySize = _runtimeSettings.Value.MaxRequestLength.HasValue
? _runtimeSettings.Value.MaxRequestLength.Value * 1024
: uint.MaxValue; // ~4GB is the max supported value for IIS and IIS express.
}
}
}

View File

@@ -11,8 +11,8 @@ namespace Umbraco.Cms.Web.Common.Security
public ConfigureKestrelServerOptions(IOptions<RuntimeSettings> 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;
// convert from KB to bytes, 52428800 bytes (50 MB) is the same as in the IIS settings
options.Limits.MaxRequestBodySize = _runtimeSettings.Value.MaxRequestLength.HasValue ? _runtimeSettings.Value.MaxRequestLength.Value * 1024 : 52428800;
}
}
}

View File

@@ -5,4 +5,4 @@
<clientCache cacheControlCustom="private" cacheControlMode="UseMaxAge" cacheControlMaxAge="3.00:00:00" />
</staticContent>
</system.webServer>
</configuration>
</configuration>