Germstorm
Germstorm

Reputation: 9849

ASP.Net web service large URL

We have to send a large packet to an ASP.Net web service through the URL. We cannot use POST for certain reasons, so we are URL encoding an XML package and we make a GET request to the service.

http://service.example.com/collect?content=AAAAAAAA...(+5000 characters)

The service responds with

Error 404 - File or directory not found.

I have read that there is no error code for max-content-length-exceeded so IIS sends back this 404 error. Knowing that, I have changed the configuration in the following way to allow large requests:

Changed query string length, max URL length, max request length and deactivated validation

<httpRuntime 
    requestValidationMode="2.0" 
    maxQueryStringLength="262144000" 
    maxUrlLength="262144000" 
    maxRequestLength="262144000" />
...
<pages validateRequest="false" />
...
<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="262144000" />
        </requestFiltering>            
    </security>
</system.webServer>

I still receive the same error. How do I make a request to my web service with an extremely large/long URL?

Update 1

I am not sending images. The content is something like:

<packet date="1243235246436">
    <param type="1" id="45">
        5
    </param>
</packet>

without the new line characters and URL encoded.

Update 2

After setting the limits to a larger number in the IIS Request Filtering the 404 is now transformed to

HTTP Error 400. The size of the request headers is too long.

This is because the size of the headers is too large now. Tried to follow the instructions from this article by adding the MaxFieldLength and MaxRequestBytes registry entries, but I am still capped at 16k URL length. What can I do to be able to send 1,000,000 long URLs? Is this even possible? What can I do to send at least 65k long URLs? This is the max length a header can have, but my settings are not taken into consideration.

Upvotes: 1

Views: 1123

Answers (2)

Vinay
Vinay

Reputation: 11

A GET request is only limited by a browser's limit on the length of the URL string. In IE it is 2,083 characters, minus the number of characters in the actual path. Other browsers do not have a clearly defined limit on the length of the URL string. These articles might be helpful to you.

http://www.boutell.com/newfaq/misc/urllength.html

http://support.microsoft.com/kb/q208427

RFC 2616, "Hypertext Transfer Protocol -- HTTP/1.1," does not specify any requirement for URL length, so browsers are free to stipulate what they deem fit.

Upvotes: 1

naivists
naivists

Reputation: 33531

The MSDN documentation of maxQueryStringLength also talks about IIS filtering in case of very long URLs. Have you checked this ? The property names mentioned there are a bit different: maxQueryString, maxUrl.

Upvotes: 2

Related Questions