【问题标题】:Http message with with absolute URL instead of absolute path gives 404 error using IIS使用绝对 URL 而不是绝对路径的 Http 消息在使用 IIS 时会出现 404 错误
【发布时间】:2019-12-26 16:25:34
【问题描述】:

当使用 C# 中的 HttpClient 发送消息时,它将向服务器发送以下内容:

Delete http://test.com/v1/client HTTP/1.1
Host: test.com
Content-Length: 0

这会导致来自 IIS 服务器的 404 消息:

HTTP/1.1 404 Not Found
Cache-Control: private
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/10.0
X-Powered-By: ASP.NET
Date: Wed, 21 Aug 2019 09:56:06 GMT
Content-Length: 5100

...

但是使用绝对路径而不是绝对 URL 发送以下消息:

Delete /v1/client HTTP/1.1
Host: test.com
Content-Length: 0

按预期返回 200 条消息。

我需要在我的 IIS 服务器上进行哪些更改,以便它也可以接受使用绝对 URL 的 HTTP 消息?

specifications 表示两者都是允许的,因此 HttpClient 没有问题。

IIS 日志

#Software: Microsoft Internet Information Services 10.0
#Version: 1.0
#Date: 2019-08-22 08:17:09
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
2019-08-22 08:17:09 127.0.0.1 Delete /v1/client/webhook - 80 - 127.0.0.1 - - 404 4 2 3

看起来像 404.4 - No handler configured 错误。

【问题讨论】:

  • 读取 IIS 日志文件,看看你遇到了什么样的 404,support.microsoft.com/en-ca/help/943891/…
  • 请检查您输入的域名是否正确,并检查 iis 绑定。
  • @LexLi #Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken 2019-08-22 08:17:29 127.0.0.1 删除 /v1/client- 80 - 127.0.0.1 - - 404 4 2 3
  • 我已经用 IIS 日志和 404.4 No handler configured 错误更新了原始问题。
  • 我尝试了以下解决方案:stackoverflow.com/a/7895377/3576578 但它不起作用,它给了我严重的网关错误。

标签: http iis


【解决方案1】:

我发现 IIS 无法处理带有小写字母的“Get”方法的问题。如果我发送“GET”,一切正常。

【讨论】:

    猜你喜欢
    • 2023-03-15
    • 2016-11-14
    • 1970-01-01
    • 2016-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-12
    相关资源
    最近更新 更多