我正在尝试使用CORS请求但是在部署的服务器上运行时遇到了问题
我正在使用thinktecture identity model设置我的CORS,它在IIS-express的本地实例上运行时效果很好但在网站的正确IIS 7.5版本上失败。
这是本地版本,效果很好
OPTIONS http://local.api.mysite.org:57339/api/search HTTP/1.1
Host: local.api.mysite.org:57339
Connection: keep-alive
Access-Control-Request-Method: POST
Origin: http://local.mysite.org:62747
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36
Access-Control-Request-Headers: accept, origin, content-type
Accept: */*
Referer: http://local.mysite.org:62747/search
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
=======
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Server: Microsoft-IIS/8.0
Access-Control-Allow-Origin: http://local.mysite.org:62747
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: accept,origin,content-type
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?QzpcR2l0XGxpdmVzLWRldmVsb3BcQnJpZ2h0U29saWQuTGl2ZXMuV2ViQXBpXGFwaVxzZWFyY2g=?=
X-Powered-By: ASP.NET
Date: Tue, 01 Oct 2013 21:28:06 GMT
Content-Length: 0
这是部署版本并失败
OPTIONS http://betatest.api.mysite.org/api/search HTTP/1.1
Host: betatest.api.mysite.org
Connection: keep-alive
Access-Control-Request-Method: POST
Origin: http://betatest.mysite.org
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36
Access-Control-Request-Headers: accept, origin, content-type
Accept: */*
Referer: http://betatest.mysite.org/search
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
=======
HTTP/1.1 200 OK
Allow: OPTIONS, TRACE, GET, HEAD, POST
Server: Microsoft-IIS/7.5
Public: OPTIONS, TRACE, GET, HEAD, POST
X-Powered-By: ASP.NET
Date: Tue, 01 Oct 2013 21:31:24 GMT
Content-Length: 0
GETS在已部署的实例上运行良好,但在POSTS上运行不正常。
似乎OPTIONS预检响应在IISExpress和IIS7.5之间有所不同
我已经尝试过清理缓存,但这并没有什么不同。
答案 0 :(得分:2)
听起来生产服务器上的WebDAV可能正在劫持OPTIONS请求。此博客文章介绍了如何为应用程序禁用WebDAV: