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:
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,4 +5,4 @@
|
||||
<clientCache cacheControlCustom="private" cacheControlMode="UseMaxAge" cacheControlMaxAge="3.00:00:00" />
|
||||
</staticContent>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
</configuration>
|
||||
|
||||
Reference in New Issue
Block a user