CORS request aborted when adding a custom header in AJAX CORS request in IE10

二次信任 提交于 2019-12-24 14:57:35

问题


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");

This works fine in other browsers but not in IE10!

ONE REMARK:

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 !

In IE 10 web developer tools I can see an error message:

SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied

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.

The request is aborted right away, it never reaches the message handler!


回答1:


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

What I have done is:

  1. I went to IIS where my webapi is hosted and
  2. Click/mark my web application which is hosting my webapi and
  3. Go to SSL Settings-> Check Ignore Client Certificates!.

Now the the preflight CORS request goes through using IE10.



来源:https://stackoverflow.com/questions/36985915/cors-request-aborted-when-adding-a-custom-header-in-ajax-cors-request-in-ie10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!