While developing REST-services using ASP.Net Core and using kestrel I have never had an issue with the query string being to long. That issue may enter when I deploy the service to IIS. Even though ASP.Net Core services is self hosted and using Kesterel behind the scenes, IIS is functioning as a reversed proxy. Therefore the querystring limitations are valid.
When I first entered this issue, I increased the maxUrlLength then also increased the request limits. Setting the request limites can also be done in the IIS GUI. For me personally, I do not like setting anything by hand in the IIS GUI. Changeing the web.config instead, I will have the change everywhere the application is deployed and the changes backed up in version control.
<configuration> <system.web> <httpRuntime maxUrlLength="500" /> </system.web> <system.webServer> <security> <requestFiltering> <requestLimits> <headerLimits> <add header="Content-type" sizeLimit="100" /> </headerLimits> </requestLimits> </requestFiltering> </security> </system.webServer> </configuration>
Increasing the allowed querystring length in the web.config file was not enough, IIS also use the limitation in HTTP.Sys. To change values for HTTP.Sys it is needed to change some registry variables. The boring thing about this is that the server require a restart to make the changes take effect.
Changes that need to be made is in the registry,
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters below are the keys that need to be set.
UrlSegmentMaxLength DWORD Hexadecimal 400
Hexadecimal value 400 is in decimal value 1024. A great resource to check hexadecimal value Hex to Decimal converter.