【问题标题】:Max querystring length on asp .net 2.0asp .net 2.0中的最大查询字符串长度
【发布时间】:2012-02-13 22:17:43
【问题描述】:

我正在使用 ASP .NET 2.0 版和 IIS 6。我通过调用其 URL 并将查询字符串传递给它来从主页调用弹出 aspx 页面。 对于特定情况,我的查询字符串的长度超过 2000 个字符。所以弹出屏幕第一次打开很好,但是每当弹出屏幕中有回发时,我都会收到互联网连接错误。 我确信这是因为查询字符串的长度很大,因为当我减少查询字符串的长度时它可以正常工作。

有没有一种方法可以增加所传递的查询字符串的最大允许长度。是否可以通过 web.config 或在某些 IIS 设置中进行配置。

【问题讨论】:

  • 如果可能,不要在 url 中发送这么长的字符串,尝试使用 FORM 的 POST 方法。

标签: query-string


【解决方案1】:

以下是我用于 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>

参考

  1. request exceeds the configured maxQueryStringLength when using [Authorize]
  2. WCF says it exceeds maximum query string value while it is not

【讨论】:

    【解决方案2】:

    httpRuntime 元素的属性maxQueryStringLength 仅受 4.0 及更高版本支持。 您必须使用 IIS 设置来控制最大查询字符串限制。

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

    【讨论】:

      【解决方案3】:

      默认为 2048。查看this 帖子 (MSDN)。在 web.config 的 httpRuntime 部分设置 maxQueryStringLength

      请在同一篇文章中查看相关要求。

      希望这对你有用。

      【讨论】:

        猜你喜欢
        • 2013-12-24
        • 2018-11-11
        • 2011-12-01
        • 2021-12-27
        • 2016-09-11
        • 2010-10-23
        • 2020-07-29
        • 2010-09-13
        • 2016-11-23
        相关资源
        最近更新 更多