我正在对 asp.net mvc Controller 执行以下 jquery ajax 调用,该 Controller 可以工作,但是在 firebug 控制台上,它似乎执行了 3 次。前两次返回 401 Unauthorized,最后一次返回 200 Ok。谁能解释一下当我提出此请求时发生的情况以及如何阻止初始调用失败。
$.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);
}
});
最佳答案
当我在 Firefox 中调试时,我注意到这种情况发生在我身上。我发现的修复方法是将站点添加到 firefoxs about:config 中的“network.automatic-ntlm-auth.trusted-uris”列表中。
如果是本地开发服务器导致问题,请务必包含端口。
关于jquery ajax 调用 asp.net mvc 应用程序获得两个未经授权的响应,然后确定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2071221/