HttpRuntimeSection.MaxRequestLength 属性

定义

获取或设置请求的最大大小。Gets or sets the maximum request size.

public:
 property int MaxRequestLength { int get(); void set(int value); };
[System.Configuration.ConfigurationProperty("maxRequestLength", DefaultValue=Mono.Cecil.CustomAttributeArgument)]
[System.Configuration.IntegerValidator(MinValue=0)]
public int MaxRequestLength { get; set; }
member this.MaxRequestLength : int with get, set
Public Property MaxRequestLength As Integer

属性值

请求的最大大小(以千字节为单位)。The maximum request size in kilobytes. 默认大小为 4096 KB (4 MB)。The default size is 4096 KB (4 MB).

属性

异常

选定值小于 RequestLengthDiskThresholdThe selected value is less than RequestLengthDiskThreshold.

示例

下面的示例演示如何获取当前MaxRequestLength属性值。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;
' Get the MaxRequestLength property value.
Response.Write("MaxRequestLength: " & _
  configSection.MaxRequestLength & "<br>")

' Set the MaxRequestLength property value to 2048 kilobytes.
configSection.MaxRequestLength = 2048

注解

MaxRequestLength属性指定输入流的缓冲阈值的限制。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.

分配给此属性的值应大于或等于赋RequestLengthDiskThreshold给属性的值。The value assigned to this property should be greater or equal to value assigned to the RequestLengthDiskThreshold property.

适用于