如何URL的长可以在Internet Explorer 9走?如何URL的长可以在Internet

2019-05-12 04:20发布

Internet Explorer的以前的版本上嘶哑网址超过2,083个字符(见http://support.microsoft.com/kb/208427 )。 与此同时,火狐,Opera和Safari至少可以处理80,000。

第9版带来了很多的改进。 是URL的长度是其中之一吗?

Answer 1:

这不是最准确的答案,但它下面的一个链接时,看起来像在地址栏中输入2083个字符和5165个字符。

(不以任何方式正式,只是插入一个URL 41000个字符到测试HTM文件,并使用Javascript功能来查询URL长度)。

更新:

重现性试验,创建一个锚元素,其href属性6000个字符的HTML文件。 打开浏览器中的文件,然后单击链接。 然后弹出打开控制台,并检查window.location.href.length

继今天在IE9此过程中,它会报告长度5165个字符。 如果我在地址栏手动加载相同的URL,它报告2083个字符。

对于它的价值,IE浏览器似乎在发送请求之前截断URL。 如果我把24000个字符的URL在锚的href属性,IE将遵循链接,但在结果页的报告的5​​165个字符的URL长度。 继从我的测试服务器的HTTP响应414在Chrome结果相同的链接。



Answer 2:

我得到一个网址5120个字符的Internet Explorer 9。

决不是一个明确的测试,但下面演示了在锚标签的href属性的URL长度的快速检查。

<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>


Answer 3:

我写了这个测试,保持上添加'a'为参数,直到浏览器失败

C#部分:

[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();
}

视图:

<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>

我加入另外的限制IISExpress applicationhost.configweb.config设置maxQueryStringLength="32768"

还增加了对配置

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

这并没有在所有帮助,最后决定使用Fiddler从头部取出引荐。

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

这确实很好。

在IE9我

Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
4043


文章来源: How long of a URL can Internet Explorer 9 take?