Skip to content

Commit 18a3133

Browse files
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 <[email protected]> * Add link to documentation Co-authored-by: Mole <[email protected]>
1 parent d9bdd81 commit 18a3133

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ public static IUmbracoBuilder AddUmbraco(
109109
var appCaches = AppCaches.Create(requestCache);
110110

111111
services.ConfigureOptions<ConfigureKestrelServerOptions>();
112-
services.ConfigureOptions<ConfigureIISServerOptions>();
113112
services.ConfigureOptions<ConfigureFormOptions>();
114113

115114
IProfiler profiler = GetWebProfiler(config);
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1+
using System;
12
using Microsoft.AspNetCore.Builder;
23
using Microsoft.Extensions.Options;
34
using Umbraco.Cms.Core.Configuration.Models;
45

56
namespace Umbraco.Cms.Web.Common.Security
67
{
8+
[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")]
79
public class ConfigureIISServerOptions : IConfigureOptions<IISServerOptions>
810
{
911
private readonly IOptions<RuntimeSettings> _runtimeSettings;
1012

11-
public ConfigureIISServerOptions(IOptions<RuntimeSettings> runtimeSettings) => _runtimeSettings = runtimeSettings;
13+
public ConfigureIISServerOptions(IOptions<RuntimeSettings> runtimeSettings) =>
14+
_runtimeSettings = runtimeSettings;
15+
1216
public void Configure(IISServerOptions options)
1317
{
1418
// convert from KB to bytes
15-
options.MaxRequestBodySize = _runtimeSettings.Value.MaxRequestLength.HasValue ? _runtimeSettings.Value.MaxRequestLength.Value * 1024 : uint.MaxValue; // ~4GB is the max supported value for IIS and IIS express.
19+
options.MaxRequestBodySize = _runtimeSettings.Value.MaxRequestLength.HasValue
20+
? _runtimeSettings.Value.MaxRequestLength.Value * 1024
21+
: uint.MaxValue; // ~4GB is the max supported value for IIS and IIS express.
1622
}
1723
}
1824
}

src/Umbraco.Web.Common/Security/ConfigureKestrelServerOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ public class ConfigureKestrelServerOptions : IConfigureOptions<KestrelServerOpti
1111
public ConfigureKestrelServerOptions(IOptions<RuntimeSettings> runtimeSettings) => _runtimeSettings = runtimeSettings;
1212
public void Configure(KestrelServerOptions options)
1313
{
14-
// convert from KB to bytes
15-
options.Limits.MaxRequestBodySize = _runtimeSettings.Value.MaxRequestLength.HasValue ? _runtimeSettings.Value.MaxRequestLength.Value * 1024 : long.MaxValue;
14+
// convert from KB to bytes, 52428800 bytes (50 MB) is the same as in the IIS settings
15+
options.Limits.MaxRequestBodySize = _runtimeSettings.Value.MaxRequestLength.HasValue ? _runtimeSettings.Value.MaxRequestLength.Value * 1024 : 52428800;
1616
}
1717
}
1818
}

src/Umbraco.Web.UI.Client/src/web.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
<clientCache cacheControlCustom="private" cacheControlMode="UseMaxAge" cacheControlMaxAge="3.00:00:00" />
66
</staticContent>
77
</system.webServer>
8-
</configuration>
8+
</configuration>

0 commit comments

Comments
 (0)