How long of a URL can Internet Explorer 9 take?
Asked Answered
U

3

30

Past versions of Internet Explorer croaked on web addresses longer than 2,083 characters (see http://support.microsoft.com/kb/208427). Meanwhile, Firefox, Opera, and Safari can handle at least 80,000.

Version 9 brings many improvements. Is URL length is one of them?

Unicef answered 15/9, 2010 at 19:21 Comment(5)
Belongs on superuser.comFabaceous
@fahd no it doesn't - it's essential info for web developersPrudence
Length is not all that matters... it's about how you can use it - servers may have a significantly smaller limit to protect against some exploits and unauthorized intrusion.Smote
@Archimedix absolutely. I'm not saying it's a good thing to go too far beyond a few kilobytes in URL length. But knowing where IE9's limits are is a legitimate thing to ask.Prudence
IE9 has various limits (address bar, A HREF, Location header, etc). URLs under 2083 characters will work everywhere. Longer URLs can be resolved and navigated, but cause assorted problems (e.g. results will not be cached) and should be avoided if at all possible.India
A
18

Not the most precise answer, but it looks like 2083 characters in the address bar and 5165 characters when following a link.

(Not official in any way, just plugged a URL with 41,000 chars into a test HTM file and used Javascript to query the URL length.)

Update:

To reproduce the test, create an HTML file with an anchor element whose HREF attribute is 6000 characters long. Open the file in your browser and click the link. Then pop open the console and check window.location.href.length.

Following this procedure in IE9 today, it reports the length as 5165 characters. If I load the same URL manually through the address bar, it reports 2083 characters.

For what it's worth, IE seems to truncate the URL before sending the request. If I put a URL of 24,000 characters in the anchor's HREF attribute, IE will follow the link but the resulting page reports a url length of 5165 characters. Following the same link in Chrome results in a HTTP 414 response from my test server.

Abolish answered 15/9, 2010 at 19:43 Comment(1)
I haven't seen any documentation on the 5150 cap in links before, but it would definitely explain some issues I'm having since URLs in my links > 2083 chars are working, yet fail when put in the address bar. Is this just empirical--did you just try larger URLs until they failed?Wyne
M
10

I get 5120 characters in a url for internet explorer 9.

By no means a definitive test but the following demonstrates a quick check for url length of a href attribute in an anchor tag.

<html>
    <head>
        <script type="text/javascript">
            function init() {
                var anchor = document.getElementById('anc');
                var valid = true;
                var url = 'http://google.com/?search=';
                var count = url.length;

                while(valid) {
                    url = url + '1';
                    anchor.href = url;
                    count++;
                    valid = anchor.href == url;

                    if(count > 100000) {
                        alert('Test reached 100,000, stopping...');
                        valid = false;
                    }
                }
                alert('Complete, count = ' + count);
            }
        </script>
    </head>
    <body onload="init()">
        <a id="anc" href="http://google.com/">Test</a>
    </body>
</html>
Margaux answered 10/5, 2011 at 14:50 Comment(1)
Sounds plausible - the IE9 release notes included the following: "IE9 features improved support for “Bookmarklets”—URL length limits were relaxed." No specifics unfortunately. RE your test - the max length of in-page HREFs is not necessarily the same as the max length of URL that the browser will transmit (e.g., via address bar). Need to verify by submitting and checking server logs to see at what point truncation occurs (or an error?). Anyone have definitive info for IE9?Arboretum
C
1

I wrote this test that keeps on adding 'a' to parameter until browser fails

C# part:

[AcceptVerbs(HttpVerbs.Get)]
public ActionResult ParamTest(string x)
{
    ViewBag.TestLength = 0;
    if (!string.IsNullOrEmpty(x))
    {
        System.IO.File.WriteAllLines("c:/result.txt", 
                       new[] {Request.UserAgent, x.Length.ToString()});
        ViewBag.TestLength = x.Length + 1;
    }

    return View();
}

View:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<script type="text/javascript">
    $(function() {
        var text = "a";
        for (var i = 0; i < parseInt(@ViewBag.TestLength)-1; i++) {
            text += "a";
        }

        document.location.href = "http://localhost:50766/Home/ParamTest?x=" + text;
    });
</script>

I added additional limits to IISExpress applicationhost.config and web.config setting maxQueryStringLength="32768".

also Added to config

<headerLimits>
    <add header="Content-type" sizeLimit="32768" />
</headerLimits>

which didn't help at all, Finally decided to use fiddler to remove referer from header.

static function OnBeforeRequest(oSession: Session) {
if (oSession.url.Contains("localhost:50766")) {
        oSession.RequestHeaders.Remove("Referer");
        }

Which did nicely.

On IE9 I got

Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
4043
Carlow answered 19/7, 2016 at 15:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.