-
-
Notifications
You must be signed in to change notification settings - Fork 773
Description
Is there an existing issue for this?
- I have searched the existing issues
What happened?
The default configuration for requestLengthDiskThreshold in web.config is using a value of 81920, which translates to 80MB, while the maxRequestLength is 28672, which translates to 28MB.
The default value from .net is 80 (as in 80KB). source
In the same source provided above, there is also a RequestLengthDiskThresholdBytes property. This property is the one used by HttpRequest class to create its internal content buffer, which then gets used by HttpRequest.InputStream.
I also looked at the values in Immediate Window, and these were the values:
> System.Web.Configuration.RuntimeConfig.GetConfig(System.Web.HttpContext.Current).HttpRuntime
{System.Web.Configuration.HttpRuntimeSection}
AllowDynamicModuleRegistration: true
ApartmentThreading: false
AppRequestQueueLimit: 5000
AsyncPreloadMode: None
CurrentConfiguration: null
DefaultRegexMatchTimeout: {00:00:00}
DelayNotificationTimeout: {00:00:00}
ElementInformation: {System.Configuration.ElementInformation}
ElementProperty: {System.Configuration.ConfigurationElementProperty}
Enable: true
EnableHeaderChecking: true
EnableKernelOutputCache: true
EnableVersionHeader: false
EncoderType: "System.Web.Util.HttpEncoder"
EvaluationContext: {System.Configuration.ContextInformation}
ExecutionTimeout: {00:20:00}
FcnMode: Single
HasContext: true
LockAllAttributesExcept: {System.Configuration.ConfigurationLockCollection}
LockAllElementsExcept: {System.Configuration.ConfigurationLockCollection}
LockAttributes: {System.Configuration.ConfigurationLockCollection}
LockElements: {System.Configuration.ConfigurationLockCollection}
LockItem: false
MaxQueryStringLength: 2048
MaxRequestLength: 28672
MaxUrlLength: 2048
MaxWaitChangeNotification: 0
MinFreeThreads: 8
MinLocalRequestFreeThreads: 4
Properties: {System.Configuration.ConfigurationPropertyCollection}
RelaxedUrlToFileSystemMapping: false
RequestLengthDiskThreshold: 81920
RequestPathInvalidCharacters: "<,>,*,%,:,\\,?"
RequestValidationMode: {2.0}
RequestValidationType: "System.Web.Util.RequestValidator"
RequireRootedSaveAsPath: true
SectionInformation: {System.Configuration.SectionInformation}
SendCacheControlHeader: true
ShutdownTimeout: {00:02:00}
TargetFramework: "4.7.2"
UseFullyQualifiedRedirectUrl: true
WaitChangeNotification: 0
> System.Web.Configuration.RuntimeConfig.GetConfig(System.Web.HttpContext.Current).HttpRuntime.RequestLengthDiskThresholdBytes
83886080
Looks like when loading the values from web.config, the xml deserialization that creates the System.Web.Configuration.HttpRuntimeSection instance does not hit the validation that is part of the RequestLengthDiskThreshold property setter, but if I try to set the value to the one from web.config through Immediate Window I get the intended validation exception:
System.Web.Configuration.RuntimeConfig.GetConfig(System.Web.HttpContext.Current).HttpRuntime.RequestLengthDiskThreshold = 81920
'System.Web.Configuration.RuntimeConfig.GetConfig(System.Web.HttpContext.Current).HttpRuntime.RequestLengthDiskThreshold = 81920' threw an exception of type 'System.Configuration.ConfigurationErrorsException'
BareMessage: "The property 'RequestLengthDiskThreshold' must be less than or equal to the 'MaxRequestLength' property."
Data: {System.Collections.ListDictionaryInternal}
Errors: {System.Configuration.ConfigurationException[1]}
Filename: "D:\\wwwroot\\site\\web.config"
HResult: -2146232062
HelpLink: null
InnerException: null
Line: 164
Message: "The property 'RequestLengthDiskThreshold' must be less than or equal to the 'MaxRequestLength' property. (D:\\wwwroot\\site\\web.config line 164)"
Source: "System.Web"
StackTrace: null
TargetSite: null
another proof, a request with 1.2MB content with _data in memory and no _file created and the same value for _fileThreshold
Steps to reproduce?
none
Current Behavior
No response
Expected Behavior
No response
Relevant log output
Anything else?
A related discussion took place in #5778 and associated PR.
Affected Versions
10.1.2 (latest v10 release)
What browsers are you seeing the problem on?
No response
Code of Conduct
- I agree to follow this project's Code of Conduct