.NET How to increase allowed GET request URL lengt

2019-08-12 17:33发布

问题:

I am receiving callback from bank, but it only works with one request which has 1960 characters in get request.

The other longer request with more parameters is 2236 characters long, which doesn't reach our MVC action.

I already tried changing maxUrlLength to 4000(4000 characters?) in web.config:

<httpRuntime targetFramework="4.5" maxRequestLength="2097151" maxUrlLength="4000" />

But still first response doesn't reach MVC action.

They reported from their side for longer request:

ERROR Problem with connection to the following URL

What seems to be the problem here?

回答1:

If you are using IIS 6 and above, also add following entry. This setting will be used if you have managed app pool rather than classic.

<system.web>
   <httpRuntime maxUrlLength="40960" maxQueryStringLength="2097151" />
</system.web>
<system.webServer>
<security>
   <requestFiltering>
      <requestLimits maxUrl="40960" maxQueryString="2097151" />
   </requestFiltering>
</security>
</system.webServer>