Changing the Web.config file configuration for maxQueryString+Length settings and the effect on API queries
In the context of web development and HTTP requests, both maxQueryString and maxQueryStringLength refer to certain limitations imposed on the query string portion of a URL. They each represent different aspects of the URL and serve distinct purposes. This article explains some considerations when changing the these settings within the web.config file for use with the API.
Both of these settings are currently configured to 10,000 in the default web.config file. Changing this value could cause API issues.
Explaining maxQueryString
This refers to the maximum length allowed for the entire query string in a URL. The query string is the part of a URL that follows the question mark (?) and contains key-value pairs separated by ampersands (&). ThemaxQueryString setting specifies the maximum number of characters that can be present in the entire query string.
- For example, if
maxQueryStringis set to 2048, any URL with a query string exceeding 2048 characters would be rejected or cause an error. This setting helps prevent excessively long URLs that could potentially cause issues, such as exceeding server limits or leading to security vulnerabilities.
Explaining maxQueryStringLength
- This refers to the maximum length allowed for an individual key or value within a query string. It defines the limit for a single parameter or value in the query string.
- For instance, if
maxQueryStringLengthis set to 255, any key or value within the query string that exceeds 255 characters would be considered invalid. This setting aims to prevent excessively long parameter values that might cause problems or lead to potential vulnerabilities.
Check your settings
Confirm that these two lines exist in the web.config and that the values are set appropriately (taking into account the above explanation for each setting):
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="524288000" maxQueryString="10000" />
</requestFiltering>
</security>
<system.web>
<httpRuntime targetFramework="4.7.2" executionTimeout="1800" maxRequestLength="512000" maxQueryStringLength="10000" requestValidationMode="2.0" enableVersionHeader="false" />
<compilation optimizeCompilations="true" targetFramework="4.7.2">
<assemblies>