some_bloody_fool some_bloody_fool - 4 months ago 41
C# Question

How to configure the web.config to allow requests of any length

I am building a site in which i would like to create a file client side from the value of a textarea element.

I have the code in place to do this, but i am getting this error


HTTP Error 404.15 - Not Found The request filtering module is
configured to deny a request where the query string is too long.


Is there a way to override this so that I am able to process requests of any size?

If not, is there a way to generate files client side without using the filesystem/active x object?

thanks

Answer

Add the following to your web.config:

<system.webServer>
  <security>
    <requestFiltering>
      <requestLimits maxQueryString="32768"/>
    </requestFiltering>
  </security>
</system.webServer>

See:

http://www.iis.net/ConfigReference/system.webServer/security/requestFiltering/requestLimits

Updated to reflect comments.

requestLimits Element for requestFiltering [IIS Settings Schema]

You may have to add the following in your web.config as well

 <httpRuntime maxQueryStringLength="32768" maxUrlLength="65536"/>

See: httpRuntime Element (ASP.NET Settings Schema)

Of course the numbers (32768 and 65536) in the config settings above are just examples. You don't have to use those exact values.