【问题标题】:IIS 8.5 400 Bad Request - Invalid URLIIS 8.5 400 错误请求 - 无效的 URL
【发布时间】:2016-10-31 16:24:30
【问题描述】:

我收到了对此类 URL 的请求: https://xxx/test/%81

这会导致 400 Bad Request - Invalid URL

我尝试在 web.config 中设置:

<httpRuntime requestValidationMode="2.0" relaxedUrlToFileSystemMapping="true" requestPathInvalidCharacters=""/>

但这无济于事。

我也尝试使用自定义请求验证器:

<httpRuntime requestValidationType="MyNamespace.CustomRequestValidation"/>

但 IIS 在使用自定义验证器之前返回 400。

我还能做些什么来让 IIS 接受这个 URL?

谢谢。

【问题讨论】:

    标签: asp.net iis iis-8.5


    【解决方案1】:

    根据 https://www.iis.net/learn/troubleshoot/diagnosing-http-errors/troubleshooting-http-400-errors-in-iis HTTP 400 的根本问题是客户端向 IIS 发送的请求违反了 HTTP.sys 正在执行的一个或多个规则。

    此处描述了 Windows 的 Http.sys 注册表设置: https://support.microsoft.com/en-us/kb/820129

    所以,在我的情况下,问题是通过在 HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters 下创建以下 DWORD 值作为 IIS 机器来解决的:

    AllowRestrictedChars = 1
    EnableNonUTF8 = 1
    

    将这些更改应用到注册表后,必须重新启动 IIS 机器

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-19
      • 2014-12-11
      • 1970-01-01
      • 2015-05-11
      • 1970-01-01
      • 1970-01-01
      • 2014-08-23
      • 2019-05-10
      相关资源
      最近更新 更多