find and solve || findandsolve.com
Please wait.....

Fix max URL and query string length with maxQueryString setting in the applicationhost.config or web.config file

Fix max URL and query string length with maxQueryString setting in the applicationhost.config or web.config file

I am building a site in which i would like to post ViewModel List in my controller using ajax from client site.When I have post my ViewModel list in Controller this type of issue hase been occured like as given below.

Most likely causes:

Request filtering is configured on the Web server to deny the request because the query string is too long.

Things you can try:

Verify the configuration/system.webServer/security/requestFiltering/[email protected] setting in the applicationhost.config or web.config file.

More Information:

This is a security feature. Do not change this feature unless the scope of the change is fully understood. You can configure the IIS server to reject requests whose query string is greater than a specified value. If the request's query string is greater than the configured value, this error is returned. If the allowed length of the query string needs to be increased, modify the configuration/system.webServer/security/requestFiltering/[email protected] setting.

Answer


Option 1.

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


Option 2.

The fix is to change the maxQueryString setting (or maxUrl if the problem is in the path). To do so, modify the security element in the web.config file:

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


Option 3.

In the  case ( Visual Studio 2015 / IIS Express / ASP.NET MVC 5 app / .Net Framework 5 ) what really worked after 30 minutes of trial and error was setting the maxQueryStringLength property in the <httpRuntime> tag:

<httpRuntime targetFramework="4.5" maxQueryStringLength="10240" enable="true" />

maxQueryStringLength defaults to 2048.


Option 4.

See more Details:

When request filtering blocks an HTTP request because an HTTP request exceeds the request limits, IIS 7 will return an HTTP 404 error to the client and log one of the following HTTP statuses with a unique substatus that identifies the reason that the request was denied:

https://docs.microsoft.com/en-us/iis/configuration/system.webserver/security/requestfiltering/requestlimits

Option 5.

In Upload Content case

<configuration>
  <system.webServer>
    <security>
      <requestFiltering>
     <requestLimits maxAllowedContentLength="104857600" />
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>







Selena  Kandakar

Selena Kandakar

I like working on projects with a team that cares about creating beautiful and usable interfaces.

Comments



Report Response