HttpRuntimeSection.MaxRequestLength Property

Definition

Gets or sets the maximum request size.

C#
[System.Configuration.ConfigurationProperty("maxRequestLength", DefaultValue=4096)]
[System.Configuration.IntegerValidator(MinValue=0)]
public int MaxRequestLength { get; set; }

Property Value

The maximum request size in kilobytes. The default size is 4096 KB (4 MB).

Attributes

Exceptions

The selected value is less than RequestLengthDiskThreshold.

Examples

The following example shows how to obtain the current MaxRequestLength property value.

C#
// Get the MaxRequestLength property value.
Response.Write("MaxRequestLength: " +
  configSection.MaxRequestLength + "<br>");

// Set the MaxRequestLength property value to 2048 kilobytes.
configSection.MaxRequestLength = 2048;

Remarks

The MaxRequestLength property specifies the limit for the buffering threshold of the input stream. For example, this limit can be used to prevent denial of service attacks that are caused by users who post large files to the server.

The value assigned to this property should be greater or equal to value assigned to the RequestLengthDiskThreshold property.

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1