HttpRuntimeSection.MaxRequestLength Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets or sets the maximum request size.

Namespace:   System.Web.Configuration
Assembly:  System.Web (in System.Web.dll)

[ConfigurationPropertyAttribute("maxRequestLength", DefaultValue = 4096)]
[IntegerValidatorAttribute(MinValue = 0)]
public int MaxRequestLength { get; set; }

Property Value

Type: System.Int32

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

Exception Condition

The selected value is less than RequestLengthDiskThreshold.

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.

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

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

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

.NET Framework
Available since 2.0
Return to top