Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Max querystring length on asp .net 2.0

Tags:

query-string

I am working on ASP .NET version 2.0 and IIS 6. I am calling a pop up aspx page from the main page by calling its URL and passing querystring to it. For a specific case the length of my querystring exceeds more than 2000 characters. So the pop up screen opens up fine for the first time but whenever there is a postback in that pop up screen, I get a internet connection error. I am sure this is happening because of the large length of the querystring because it works fine when I reduce the length of querystring.

Is there a way we can increase the maximum allowed length of the querystring passed. Can it be configured through web.config or in some IIS settings.

like image 486
user1157982 Avatar asked Jan 19 '12 08:01

user1157982


People also ask

What is the maximum size of query string in asp net?

The maximum length of the query string, in number of characters. The default is 2048.

Is there a limit on query string length?

RFC 2616 (Hypertext Transfer Protocol — HTTP/1.1) states there is no limit to the length of a query string (section 3.2. 1). RFC 3986 (Uniform Resource Identifier — URI) also states there is no limit, but BigIP has limited the query string to magical max value, 1354.

What is the default maximum length for URL characters in asp net?

Property Value The length of the URL, in number of characters. The default is 260.

What is MaxQueryString?

The MaxQueryString Request Filter describes the upper limit on the length of the query string that the configured IIS server will allow for websites or applications. It is recommended that values always be established to limit the amount of data will can be accepted in the query string.


3 Answers

Following is the approach I use for ASP.Net MVC 4

<system.web>

    <httpRuntime maxQueryStringLength="6000" />

  </system.web>

  <system.webServer>

        <security>

            <requestFiltering>
                <!--Query String Length-->
                <requestLimits maxQueryString="6000" />
            </requestFiltering>         
        </security>

  </system.webServer>

REFERENCE

  1. request exceeds the configured maxQueryStringLength when using [Authorize]
  2. WCF says it exceeds maximum query string value while it is not
like image 88
LCJ Avatar answered Oct 21 '22 11:10

LCJ


By default it 2048. Check this post (MSDN). Set maxQueryStringLength in httpRuntime section of your web.config.

Please check the requirements for this on the same post.

Hope this works for you.

like image 29
Amar Palsapure Avatar answered Oct 21 '22 10:10

Amar Palsapure


Attribute maxQueryStringLength of httpRuntime element is supported only by 4.0 and above. You have to use IIS settings to control max query string limits.

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

like image 3
wałdis iljuczonok Avatar answered Oct 21 '22 10:10

wałdis iljuczonok