Steven Edison
Steven Edison

Reputation: 527

Edge on Windows 10 32-Bit blocking ajax call to localhost with Network Error 0x2efd

We have an app that uses SignalR to talk to scanner drivers locally that has been in production for a couple of years working on IE, Chrome and Firefox, which do not have a problem pulling down the hubs js header file for SignalR. Once Edge came out we saw an issue with talking to localhost and after long efforts of finding a setting to allow it to communicate (and many hours with a Microsoft ticket that they found no solution), we settled on adding headers to allow Edge to grant access to domain:

Access-Control-Allow-Origin: https://localhost:11000

This seemed to work, but little did we notice that it worked for a 64-Bit Windows 10 Edge, but did not on 32-Bit Windows 10 Edge. I have spent hours lowering all security settings for all zones and disabling Protected Mode, trying different ajax tricks to pull the file, but continue to get the error:

SCRIPT7002: XMLHttpRequest: Network Error 0x2efd, Could not complete the operation due to error 00002efd.

The following pseudo code fails:

$.ajax({
    url: "https://localhost:11000/signalr/hubs",
    crossDomain: true,
    success: function (data) {
        console.log("success");
    },
    error: function (jqXHR, textStatus, errorThrown) {
        console.log("error:");
        console.log(jqXHR);
    }
});

I'm looking for any insight into settings or anything else to try, or if anyone else has seen this issue. One other piece of information, fiddler doesn't show any traffic for the call so it is being blocked by the browser it would seem. Also on the same computer that fails with Edge - IE, Chrome and FF will succeed.

Upvotes: 15

Views: 8871

Answers (5)

Mika
Mika

Reputation: 1276

I had similar problem with Edge. The fix needed changes in ajax call and server running at localhost.

In ajax call I had to change from old text/plain to application/json

contentType: 'application/json; charset=utf-8',

Local server was using Jersey so there I added ContainerResponseFilter implementation that adds Access-Control-Allow-Headers and Access-Control-Allow-Methods headers. Access-Control-Allow-Origin was in place already.

res.getHeaders().add("Access-Control-Allow-Headers", "origin, content-type, accept, authorization");
res.getHeaders().add("Access-Control-Allow-Methods", "POST, GET, OPTIONS");

Upvotes: 0

Patt Mehta
Patt Mehta

Reputation: 4194

Your request is missing the following attributes, adding which should solve the problem.

  1. Request method: GET, POST, etc.
  2. Request content-type (header): application/json, etc.
  3. Request data-type (header): json, XML, etc.

Also look at the following code snippet:

type:"POST",
contentType:"application/json; charset=utf-8",
dataType:"json"

Upvotes: 1

Atif Hussain
Atif Hussain

Reputation: 898

you can try this.

    $.ajax({
        url:url,
        type:"POST",
        data:data,
        contentType:"application/json; charset=utf-8",
        dataType:"json",
        success: function(){
        //
        }
    });

and make sure to properly provide the parameters, content-type, data-type, responseCode..etc

Upvotes: 0

VDWWD
VDWWD

Reputation: 35514

I had the same issue. While Ajax calls to a page on the same domain were working in every other browser, in Edge they wouldn't. Opening the url used for the Ajax call in a different tab would give the correct results. Adding the piece of code to the page serving the Ajax calls fixed it somehow... The code is in C# but maybe this will give a general idea how to fix it in other languages.

    if (Request.UserHostName == "127.0.0.1")
        Response.AppendHeader("Access-Control-Allow-Origin", "*");

Upvotes: 0

TechnicalTophat
TechnicalTophat

Reputation: 1725

Try it in IE compatibility mode by going into dev tools and selecting from the top drop down, if the error is still occurring with this on, chances are that it's some Windows system files that IE uses. Does this call use authentication with certificates? Maybe the certificate is out of date or Edge uses a different authentication method? Check your sources tab in IE (both compatible and non compatible) to see if the resource is being loaded, as Fiddler only captures HTTP and HTTPS traffic. That should point you in the right direction with regards to errors etc. Finally, maybe just code up a C# app that makes a request to the same URL, it's possible that the new version of .NET uses the same dependencies that could be breaking your call. If so, C# will give you enough of a descriptive error to fix the issue

Upvotes: 0

Related Questions