首页 > 解决方案 > 哪个 IIS 配置会导致特定调用出现“405 Method not allowed”错误?

问题描述

在我们当前的 WebAPI 调用中,只有少数特定的调用返回 405 错误消息(405 Method not allowed),其余的工作正常。失败的只是在特定环境中失败,在所有其他环境中,所有调用都返回 200 并且一切都是洁净的。

哪个 IIS 设置或系统设置会导致这种情况?我正在放大这个,因为这看起来更像是一个系统/配置问题。

Request URL : <hostname/GetAllStuff?userId=johndoe&sortByCustom=CreatedDate&sortByOrder=desc
    Request Method: GET
    Status Code: 405 Method Not Allowed
    Remote Address: 172.72.78.33:443
    Referrer Policy: no-referrer-when-downgrade
    Access-Control-Allow-Credentials: true
    Access-Control-Allow-Headers: Content-Type
    Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS
    Access-Control-Allow-Origin: *
    Allow: GET,POST,DELETE,PUT
    Cache-Control: no-cache
    Content-Length: 136
    Content-Type: application/json; charset=utf-8
    Date: Tue, 06 Nov 2018 17:16:28 GMT
    Expires: -1

响应看起来像这样。奇怪的是,所有 API 调用都是 1.0(api-version: 1.0),但只有几个调用会抛出这个错误,而且在特定环境中也是如此。

{ "Error": { "Code": "UnsupportedApiVersion", "Message": "API 版本 '1.0' 的请求资源不支持 HTTP 方法 'GET'。" } }

标签: asp.net-web-apiasp.net-core-webapi

解决方案


推荐阅读