Export (0) Print
Expand All

HttpRuntimeSection.MaxRequestLength Property

Gets or sets the maximum request size.

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

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

Property Value

Type: System.Int32
The maximum request size in kilobytes. The default size is 4096 KB (4 MB).

ExceptionCondition
ConfigurationErrorsException

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.

TopicLocation
How to: Upload Files with the FileUpload Web Server ControlBuilding ASP .NET Web Applications
How to: Upload Files with the FileUpload Web Server ControlBuilding ASP .NET Web Applications

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

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft