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

后端 未结 5 1518
耶瑟儿~
耶瑟儿~ 2021-02-07 11:31

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 prob

相关标签:
5条回答
  • 2021-02-07 12:17

    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", "*");
    
    0 讨论(0)
  • 2021-02-07 12:19

    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

    0 讨论(0)
  • 2021-02-07 12:25

    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");
    
    0 讨论(0)
  • 2021-02-07 12:35

    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"
    
    0 讨论(0)
  • 2021-02-07 12:36

    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

    0 讨论(0)
提交回复
热议问题