Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MaxQueryStringLength Property

HttpRuntimeSection.MaxQueryStringLength Property

.NET Framework 4.6 and 4.5

Gets or sets the maximum possible length, in number of characters, of a query string in an HTTP request.

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

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

Property Value

Type: System.Int32
The maximum length of the query string, in number of characters. The default is 2048.

The value of the MaxQueryStringLength property can be any integer, zero or larger. If the length of a query string exceeds the size limit, ASP.NET returns an HTTP 400 (Bad Request) status code.


Extremely small values can make a Web site unusable.

You can set this value in a configuration file by setting the maxQueryStringLength attribute of the httpRuntime element. For more information, see httpRuntime Element (ASP.NET Settings Schema).


There is also an IIS setting that controls query string length. See the maxQueryString attribute in Request Limits <requestLimits>.

.NET Framework

Supported in: 4.6, 4.5, 4
© 2015 Microsoft