【发布时间】:2015-12-29 22:42:54
【问题描述】:
当 CORS 被配置(并且看似工作)时,它仍然为 OPTIONS 动词返回 405。
CORS 是通过 Owin NuGet 包 Microsoft.Owin.Cors 配置的,它似乎返回了正确的标头。
当我伪造预检 OPTIONS 请求时,我注意到 Fiddler 中的问题。当我建议我从允许的域调用时,标头会正确返回,如果我建议其他域,它们正确地不存在 - 它可以工作。
但为什么是 405?
HTTP/1.1 405 Method Not Allowed
Cache-Control: no-cache
Pragma: no-cache
Allow: GET,PUT,DELETE
Content-Type: application/xml; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.0
Access-Control-Allow-Origin: @987654321@
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Thu, 01 Oct 2015 18:59:32 GMT
Content-Length: 96
<Error><Message>The requested resource does not support http method 'OPTIONS'.</Message></Error>
注意Access-Control-Allow-Origin 存在,所以我猜浏览器会没事的,还是浏览器会被否定的 405 '推迟'?
【问题讨论】:
标签: http asp.net-web-api cors owin