WCF says it exceeds maximum query string value while it is not
Asked Answered
A

1

3

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?

Autogiro answered 8/9, 2012 at 8:53 Comment(0)
P
4

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.

Politician answered 8/9, 2012 at 9:46 Comment(1)
that did the trick. it's confusing to have such a setting in two different places (i know it's probably checked at a different level and enables further optimization, but it's confusing). thanks.Trachytic

© 2022 - 2024 — McMap. All rights reserved.