我们需要发送超过 16181 个字符的获取请求。此时我们最多可以发送: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。
我错过了什么?
MaxFieldLength
和的值MaxRequestBytes
也需要在注册表项下设置HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters
为 DWORD 值。有关屏幕截图的更多详细信息,请参阅文章
HTTP 400 - Bad Request (Request Header too long)。