Problem with very large URL

5

I'm trying to pass a URL per GET and the server is returning error 404 because the URL is too large (I'm passing an XML through the URL).

I have already tried to add the MaxFieldLength variables with 1677721 and MaxRequestBytes with 1677721 in the Windows registry, according to the link below:

link

Note: The operating system is Windows Server 2012.

    
asked by anonymous 10.10.2014 / 19:59

2 answers

6

This answer is a partial translation of a reference from the SOzão


Short answer: Keep the URL in 2000 bytes

Keeping below 2k, the URL will work in almost any condition.


Long answer: first, the patterns ...

The RFC 2616 (Hypertext Transfer Protocol HTTP / 1.1) section 3.2.1 says:

  

The HTTP protocol does not place   any a priori limit on the length of
  to URI. Servers MUST be able to handle   the URI of any resource they serve,   and SHOULD be able to handle URIs of   unbounded length if they provide   GET-based forms that could generate   such URIs. A server SHOULD return   414 (Request-URI Too Long) status if a   URI is longer than the server can   handle (see section 10.4.15).

and also:

  

Note: Servers ought to be cautious   about depending on URI lengths         above 255 bytes, because some older client or proxy         implementations might not properly support these lengths.

In short, the HTTP protocol should not impose a limit on the size of a URI, and should be able to resolve GETs of any size coming from forms. If the server is unable to resolve the URI of the reported size, it should return a 414.


... and reality.

There is a search on boutell.com whose summary is:

  

Extremely long URLs are usually a   mistake URLs over 2,000 characters   will not work in the most popular web   browsers. Do not use them if you intend   your site to work for the majority of   Internet users.

Which in short says that URLs longer than 2000 characters will not work in most browsers.

In other words, even if you configure the server for larger requests, you will still probably need to do so by means other than a browser, such as cURL and the like.

    
10.10.2014 / 20:08
4

In the Web.Config file of your application on the IIS server, set the maxQueryString and maxUrl values to the desired size:

<configuration>
   <system.webServer>
      <security>
         <requestFiltering>
            <requestLimits maxQueryString="8192" maxUrl="8192" />
         </requestFiltering>
      </security>
   </system.webServer>
</configuration>

For very large files, and if the current implementation of your service allows, it would be interesting to modify your code to use POST instead of GET.

Source: IIS.net

    
10.10.2014 / 20:08