【问题标题】:IIS 7 query string lengthIIS 7 查询字符串长度
【发布时间】:2012-07-30 17:06:58
【问题描述】:

我正在使用 Asp Net Mvc 4 Web Api,我需要使用查询字符串长度 > 2000 个符号发出请求

我已经在 web.config 中设置了 maxQueryStringLength="10000" 参数。 在我的开发人员机器上一切正常 在 IIS 上,它仅在查询字符串 2000 个符号,我会收到错误:404 Not Found

有什么注意事项吗?

【问题讨论】:

  • 这是一个可怕的查询字符串,而不是它的本意。难道不能用POST代替吗?
  • @TheZ 你说得对。 Its not well. I会考虑 POST。
  • 一个帖子肯定会更可靠。最大查询字符串长度也是浏览器的属性。

标签: iis asp.net-web-api


【解决方案1】:

聚会迟到了,但是,为了摆脱它,我们改变了以下三点:

web.config中,添加httpRuntime标签属性maxQueryStringLength

<system.web>
  <httpRuntime maxQueryStringLength="32768" />
</system.web>

再次在web.config中,添加requestLimits标签属性maxQueryString

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

如果仍然无法治愈,请从 IIS 配置中的 ISAPI Filters 部分删除 UrlScan 过滤器。最后一个在我的情况下成功了。但是,请注意,它会带来安全风险。

【讨论】:

    【解决方案2】:

    你是否也设置了 maxUrl 长度?

    maxUrl 可选的 uint 属性。

    指定 URL 的最大长度,以字节为单位。

    默认值为 4096。

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

    【讨论】:

    • 不是 maxUrl,而是请求过滤中的“最大查询字符串(字节)”。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2018-09-15
    • 1970-01-01
    • 1970-01-01
    • 2011-09-02
    • 2014-08-18
    • 2018-11-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多