在IE10中的AJAX CORS请求中添加自定义标题时,CORS请求中止 [英] CORS request aborted when adding a custom header in AJAX CORS request in IE10
问题描述
当我将此标头添加到我的jQueryAjax请求时:
When I add this header to my jQueryAjax request:
headers: {
"Authorization": "SomeValue"
}
在服务器上添加授权头到
on the server I add the Authorization header to the
h.Add("Access-Control-Allow-Headers","Authorization");
这在其他浏览器中可以正常工作,但在IE10不行!
This works fine in other browsers but not in IE10!
一个备注:
我注释掉认证头,刷新页面,向我的web api发出常规GET请求,默认情况下不会触发预检请求。
在请求之后,我取消注释我的jquery请求中的自定义头,保存,刷新页面,发出一个自定义头的新请求,然后成功执行!
If I comment out the authentication header, refresh the page, issue a regular GET request to my web api which by default does not trigger a preflight request. After that request, I uncomment the custom header in my jquery request, save, refresh the page, issue a new request with a custom header, which then executes successfully !
在IE 10网络开发工具中,我可以看到一个错误消息:
In IE 10 web developer tools I can see an error message:
SCRIPT7002:XMLHttpRequest:网络错误0x80070005,访问被拒绝
SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied
SEC7118:XMLHttpRequest for
https ://mywebapi.dev/api/authentication/cors/ required跨域源
资源共享(CORS)。 cors SEC7119:XMLHttpRequest for
https://mywebapi.dev/api/authentication/cors/ 需要CORS预检。
cors SCRIPT7002:XMLHttpRequest:网络错误0x80070005,访问是
被拒绝。
SEC7118: XMLHttpRequest for https://mywebapi.dev/api/authentication/cors/ required Cross Origin Resource Sharing (CORS). cors SEC7119: XMLHttpRequest for https://mywebapi.dev/api/authentication/cors/ required CORS preflight. cors SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.
请求立即中止
推荐答案
这已经回答了在这里,并在解析器/注释部分由@EricLaw解释。现在我找到了,因为我搜索了错误代码
This is already answered here and explained by @EricLaw in the anser/comment section. I found it now, because I googled the error code
SCRIPT7002
SCRIPT7002
我所做的是:
- 我去了IIS,
- 转到SSL设置 - >检查忽略客户端证书!
- 单击/标记正在托管我的webapi和 li>
- I went to IIS where my webapi is hosted and
- Click/mark my web application which is hosting my webapi and
- Go to SSL Settings-> Check Ignore Client Certificates!.
现在使用IE10的预检CORS请求通过了。
Now the the preflight CORS request goes through using IE10.
这篇关于在IE10中的AJAX CORS请求中添加自定义标题时,CORS请求中止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!