【问题标题】:Bad Request, Header too long With Error Code 400 (Run using IIS Server .netCore Application)错误请求,标头太长,错误代码 400(使用 IIS 服务器 .net Core 应用程序运行)
【发布时间】:2021-10-22 00:53:04
【问题描述】:

大约 40-45 个 API 完成后,授权令牌的大小在 40 kb 左右。现在登录后,无论何时向服务器发送任何请求,都会出现“错误请求,标头太长”的错误。

对于 Kestrel Server,Blow 代码已解决错误 -

webBuilder.ConfigureKestrel(options =>
{
options.Limits.MaxRequestHeadersTotalSize = 1048576;
})

但是对于 IIS 服务器,我没有任何解决方案 我尝试过的解决方案是

  1. 增加了 web.config 文件中的 RequestLimit。

  2. 在中添加 MaxFieldLength 和 MaxRequestBytes HKEY_LOCAL_MACHINE/System/CurrentControlSet/Services/HTTP/Parameters

  3. 在 ConfigureServices 方法中添加以下代码

    services.Configure(options => { options.AutomaticAuthentication = true; options.ForwardWindowsAuthentication = true; });

还有更多尝试,但没有得到最终解决方案。 如果有人可以请帮助...

【问题讨论】:

标签: asp.net-core jwt


【解决方案1】:

在此处查看此链接: https://docs.microsoft.com/el-GR/troubleshoot/iis/httpsys-registry-windows

有一些注册表设置会限制 IIS maxLenght。根据您的 IIS 版本,这可能会有所不同。 您应该寻找的关键可​​能是:

MaxFieldLength(每个标头大小) MaxRequestBytes(请求的总大小)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-23
    • 2020-05-13
    • 1970-01-01
    • 2018-04-07
    • 2018-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多