Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery ajax call for asp.net mvc application getting two unauthorized reponses then Ok

I am executing the following jquery ajax call to an asp.net mvc controller which works, however on the firebug console it seems it is getting executed three times. The first two times it returns 401 Unauthorized and the final time it return 200 Ok. Could anyone shed some light on what is happening when I make this request and how I could stop the inital calls from failing.

$.ajax({
    type: 'POST',
    url: '/Core/GetVariableSet',
    dataType: 'json',
    data: {},
    success: function(response) {
        thisObject.Date = new Date(response.Date);
        thisObject.UserId = response.UserId;
        thisObject.UserName = response.UserName;
    },
    error: function(XMLHttpRequest, textStatus, errorThrown) {
        Util.errorhandling.AJAXError($('#main'), 
                       'Error Getting Variables',
                       XMLHttpRequest, 
                       textStatus, 
                       errorThrown);
    }
});
like image 586
bobwah Avatar asked Jan 15 '10 11:01

bobwah


1 Answers

I noticed this was happening to me when I was debugging in firefox. The fix I found was to add the site to the 'network.automatic-ntlm-auth.trusted-uris' list in firefoxs about:config.

Be sure to include the port if it's the local development server causing problems.

like image 163
Gary W Avatar answered Nov 02 '22 07:11

Gary W