'414 (Request-URI Too Long)

I am working on MVC platform and I am calling jqGrid using JSON GET.

I have read on Request Limits, maxQueryStringLength, maxAllowedContentLength, maximum length of URL and configure the web.config as of following

<httpRuntime maxRequestLength="2147483647" executionTimeout="1200" requestValidationMode="2.0" maxQueryStringLength="2097151" maxUrlLength ="65536"/>

&

<requestLimits maxUrl ="65536" maxAllowedContentLength="4294967295" maxQueryString ="2097151" />

But it is still giving me the 414 (Request-URI Too Long) error.

Any idea what could be the solution to this?

EDIT:

Based on Rory's comment, I changed from GET request to POST. By changing it should solve the issue. Discussion can be found here here. However, I am still facing the same issue after changing it and going through ASP.Net Core maxUrlLength



Solution 1:[1]

Two options to resolve the problem for 414 response code:

1. By POST request: Convert query string to json object and sent to API request with POST

2. By GET request: Max length of request is depend on sever side as well as client side. Most webserver have limit 8k which is configurable. On the client side the different browser has different limit. The browser IE and Safari limit to 2k, Opera 4k and Firefox 8k. means the max length for the GET request is 8k and min request length is 2k.

If exceed the request max length then the request truncated outside the limit by web server or browser without any warning. Some server truncated request data but the some server reject it because of data lose and they will return with response code 414.

Solution 2:[2]

Well, if none of the above works, you can edit http service registry settings to increase the limit.

Add following Registry dword values under HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTPFilter\Parameters

MaxFieldLength with value 65534. This Sets an upper limit for each header.

Add one more dword with MaxRequestBytes with value 16777216. This Determines the upper limit for the total size of the Request line and the headers.

Its default setting is 16 KB. If this value is lower than MaxFieldLength, the MaxFieldLength value is adjusted.

Follow how to start and stop http service

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Amol
Solution 2 Yogan Rameg