简体   繁体   中英

Cross domain ajax call windows authentication working in chrome and not working in Firefox

I have WCF service that uses windows authentication and I call this service with ajax calls. For google chrome it is work perfect as the credential are cashed but in firefox I get 401 unauthorized. I would expect that firefox will pop a pop up to fill in my credential(like when I invoke the service from the browser).

my javascript code is as follows:

 var url = "http://localhost:8732/Domain.WebServices/MyService/web/MyFunction";

    $.ajax({
        type: "GET",
        url: url,
        crossDomain: true,
        processData: false,
        xhrFields: {
            withCredentials: true
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) { alert('failed'); },
        success: function (data) { onSuccess(data); }
    });

how can I make it work in firefox when the credentials not cashed?

According to the official docs you have to ensure that server responds with Access-Control-Allow-Credentials: true header, otherwise Firefox will reject any response.

I am not sure that firefox has built in functionality to show popup and you should implement it yourself.

See more examples here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM