22

I have a very simple ajax request (see below). The server is using CORS and works fine in IE 10+, Chrome, Firefox and Opera. On Microsoft Edge however, it fails with

XMLHttpRequest: Network Error 0x80070005, Access is denied.

I have researched the posts here, here, here and here, but cannot find an answer that works. Those people have had issues with IE, but adding the contentType (not required for this get) and crossDomain has it working fine.

CanIUse seems to state that CORS is usable in Edge. The request also fails on IE9 down, but CanIUse states only partial support for CORS, so that's understandable.

Any ideas how I can fix this please?

Code:

$.ajax({
      crossDomain: true,
      url: "http://localhost:2023/api/DoAction/test",
      success: function (a) {
        var res = JSON.parse(a);
        alert(res.content);
      },
      error: function (a, e, r) {
        alert(a.responseText);
      }
    });

Update

To add further information in case it provides any clues - the ajax request is coming from Azure and posting to a localhost website created using OWIN self hosting. This is unusual, but required for the software (which can only be used locally) to get data from a cloud service. As stated, it works fine for all other browsers, Edge is the only problem.

Community
  • 1
  • 1
JsAndDotNet
  • 16,260
  • 18
  • 100
  • 123
  • What's the scheme of the URL of the page the request is coming **from**? – Quentin Jun 17 '15 at 16:14
  • Why are you setting a `content-type` header on a GET request? There's no request body to describe the content of. – Quentin Jun 17 '15 at 16:14
  • Why are you using `dataType: "json"` **and** explicitly parsing the response as JSON? That will try to double parse it, which will break in most circumstances. – Quentin Jun 17 '15 at 16:14
  • I'll try without the datatype and content type. I added them following reading up on a similar problem someone else was having with IE. I am making the request from Azure (mysite.azurewebsites.net) – JsAndDotNet Jun 17 '15 at 16:16
  • Why are you constructing your query string manually instead of using `data: {}`? You aren't escaping your variables so you might be constructing an invalid URL. – Quentin Jun 17 '15 at 16:17
  • I have made this example because it is as simple as possible. I am not escaping because I know the data going in - "1", "Darkwing" and "Duck". Sorry for any confusion - the content at /id=.... is all one string input. I'll update the question to make it more obvious. – JsAndDotNet Jun 17 '15 at 16:25
  • 1
    Updated the example in line with the update - still works in all but edge. – JsAndDotNet Jun 17 '15 at 16:27
  • 2
    Did you ever find a solution to this? I'm running into the same problem. – Amber Jul 06 '16 at 20:24

3 Answers3

10

This problem should no longer exist for developers using Microsoft Edge. If you experience issues with localhost testing, navigate to about:flags, and make sure Allow localhost loopback is checked.


Microsoft Edge does not currently support (out of the box) localhost testing. You can however enable it by following the guidance provided here: http://dev.modern.ie/platform/faq/how-can-i-debug-localhost/.

We're working on resolving this in a future release.

Sampson
  • 265,109
  • 74
  • 539
  • 565
  • 2
    Worked until Build 10162 inclusive, broken in Build 10166. AJAX request issued from localhost to a remote CORS-enabled host fail with "Network Error 0x80070005" – amartynov Jul 10 '15 at 16:08
  • I'll investigate further! – Sampson Jul 10 '15 at 17:41
  • Works again in Build 10240 :) – amartynov Jul 17 '15 at 13:51
  • 2
    I have an SSL certificate installed (real, not self-signed) and added an entry in the hosts file to point the domain to localhost. If the first AJAX call on the page is a POST, it produces a network error in Microsoft Edge (production release). If the first call is a GET, everything works fine include consequent POSTs. The problem happens again if you clear browser cache or restart IIS. – Dmitry S. Aug 02 '15 at 20:00
  • It seems Edge has CORS issues not just on localhost but in iframe too :( check this link with Edge browser: http://reportingapidotnetsample.realeyes.me/Charting – martonx Apr 07 '16 at 11:28
  • @martonx Appears to be working for me in Edge; what specifically should I see broken between the two experiences (Chrome v Edge)? – Sampson Apr 07 '16 at 17:37
  • There is an iframe which should visualize charts. It is definately not working in Edge, just in IE, FF, Chrome etc. – martonx Apr 08 '16 at 13:48
  • Right. This is what doesn't working in Edge browser. – martonx Apr 11 '16 at 07:39
  • @Sampson This error occurs in IE10 too, look at my post: [link](http://stackoverflow.com/q/36985915/2581562) ... when using Authentication header, just read the question from start to end. – Legends May 03 '16 at 21:39
  • Is there a GP setting for this? CORS on localhost works fine for me until I log on a domain user. From then on doesn't work for any user until next reboot. (IE always works) – user2543253 Jun 13 '16 at 12:10
  • Screw "until next reboot", stopped working for good on one machine. Started working on another machine with domain user after trying once with IE. I don't understand this at all. – user2543253 Jun 13 '16 at 15:01
  • Is this issue fixed yet ? We have a product that relies on a local thin client. We have a domain with a real ssl which is pointing to localhost. Ajax call works in every single browser including ie11 but not edge ? Is there any explanation on why edge can't support this after 2 years of initial release ? – Pit Digger Apr 29 '17 at 04:06
  • @Sampson Is there an issue to track for this? – cgatian Jul 20 '17 at 19:20
  • @cgatian Apologies; I'm no longer serving on the Edge team. – Sampson Jul 21 '17 at 19:01
  • The questioner did not mention anything about localhost. It does not work, anywhere. My clients and me are having the same problem. Microsoft Edge is even worse then Internet Explorer. – desloovere_j Jun 29 '18 at 08:06
0

For Build 10158 the command has changed slightly, with the rebranding of Spartan fully into Microsoft Edge, so to enable it in Microsoft Edge run the following command from an administrator command prompt:

CheckNetIsolation.exe LoopbackExempt -a -n=Microsoft.MicrosoftEdge_8wekyb3d8bbwe
David Wengier
  • 10,061
  • 5
  • 39
  • 43
0

Just before your ajax call use this : $.support.cors = true;

Cedric Michel
  • 502
  • 5
  • 13
  • 1
    This overrides jQuery's detection of the browser's support for CORS. This will either have no effect or break things. Don't do that. – Quentin Mar 20 '17 at 14:22