Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF says it exceeds maximum query string value while it is not

I have a WCF service (over a webHttpBinding) using ASP.NET 4/IIS 8 and I had no problems communicating with it using JSON with GET. However, today I needed to implement a method that sends a large query string (about 3000 characters, not that long but longer than that I've been using). I called the service and immediately got a 404 error, without even stepping into my code at my debug machine. The first thing that came to my mind is the maximum query string length limit. I've added this to my web.config:

 <system.webServer>
    <directoryBrowse enabled="true" />
    <security>
      <requestFiltering>
        <requestLimits maxQueryString="8000"></requestLimits>
      </requestFiltering>
    </security>
  </system.webServer>

Now, I am getting this server error when I call the service: The length of the query string for this request exceeds the configured maxQueryStringLength value. Weird enough, I've tried other values such as 200000, way over my query string and URL, which is about 3000 characters. Am I missing something?

like image 727
Can Poyrazoğlu Avatar asked Dec 13 '25 12:12

Can Poyrazoğlu


1 Answers

Maybe set maxQueryStringLength in the httpRuntime element.

It's a bit confusing to have two configuration settings, but I believe they can be interpreted as follows:

  • The httpRuntime maxQueryStringLength property is new to ASP.NET 4 and configures the maximum query string length that can be processed by the ASP.NET HTTP runtime. Prior to ASP.NET 4 this was a hardwired value of 2048; it can now be increased.

  • The system.web/security/requestFiltering maxQueryStringLength property is an IIS 7 setting and allows an administrator to restrict the maximum query string length. This setting isn't specific to ASP.NET.

like image 187
Joe Avatar answered Dec 15 '25 05:12

Joe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!