HTTP 错误 400。请求标头的大小太长

HTTP 错误 400。请求标头的大小太长

我们需要发送包含超过 16181 个字符的 get 请求。我们目前最多可以发送:15,861 之后我们得到:

HTTP 错误 400。请求标头的大小太长。

这是在注册表中配置为 DWORD 值的内容:

MaxFieldLength: 65534 
MaxRequestBytes: 16777216 
UrlSegmentMaxLength: 32766

在 IIS 中:

maximum allowed content length 2147483647
maximum url length 2147483647
maximum url length 2147483647

网络配置:

  <requestFiltering>
    <requestLimits maxAllowedContentLength="2147483647" maxUrl="2147483647" maxQueryString="2147483647" />
  </requestFiltering>

...

<bindings>
  <netTcpBinding>
    <binding name="largeTcpBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="2147483647" maxReceivedMessageSize="2147483647" portSharingEnabled="false" transactionFlow="false" listenBacklog="2147483647">
      <security mode="None">
        <message clientCredentialType="None" />
        <transport protectionLevel="None" clientCredentialType="None" />
      </security>
      <reliableSession enabled="false" />
    </binding>
  </netTcpBinding>
  <webHttpBinding>
    <binding name="largeRestFullBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
    <binding name="largeRestFullBindingSecoundEndPoint" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
  </webHttpBinding>
  <wsHttpBinding>
    <binding name="largeSoapBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
  </wsHttpBinding>
  <mexHttpBinding>
    <binding name="mexHttpBinding" />
  </mexHttpBinding>
</bindings>

...

  <system.web>
    <compilation debug="true" targetFramework="4.6" />
    <httpRuntime maxQueryStringLength="999999" maxUrlLength="999999" relaxedUrlToFileSystemMapping="true" targetFramework="4.6" />
    <machineKey decryptionKey="" validationKey="" />
  </system.web>

在 HTTPERR 中我得到:

2020-02-17 17:31:01 172.16.144.50 59371 172.16.144.50 80 HTTP/1.1 GET LONGURL- 400 - RequestLength -

该日志截取了部分url。

我错过了什么?

答案1

MaxFieldLength和的值MaxRequestBytes也需要在注册表中的项下设置 HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters 为 DWORD 值。

更多详细信息及截图请见文章
HTTP 400-错误请求(请求标头太长)

相关内容