1

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?

ilay zeidman
  • 2,654
  • 5
  • 23
  • 45

1 Answers1

2

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.

Yevgen Safronov
  • 3,977
  • 1
  • 27
  • 38
  • I implement the credential true that you say that why in chrome it is work ( but in chrome the credential is cashed ) but in firefox the cerdential is not cashed and it is not working... – ilay zeidman May 07 '14 at 08:54
  • Apart from client side req.withCredentials = true, for Firefox you have to check the response headers on server side returns Access-Control-Allow-Credentials: true. See here: http://arunranga.com/examples/access-control/credentialedXSRequest.txt – Yevgen Safronov May 07 '14 at 09:21
  • I check the response header with fiddler when I invoke it with chrome and it contains Access-Control-Allow-Credentials: true... – ilay zeidman May 07 '14 at 09:40
  • You definitely should add additional response headers for FF to allow cross-domain -ajax: http://stackoverflow.com/a/1678826/540802 – Yevgen Safronov May 07 '14 at 11:22