webservice使用windows身份验证,ajax请求报错401未授权的解决办法
$.ajax({
type: "GET",
url: service_url,
dataType: "xml",
data: "ParamId=" + FormId.value,
processData: false,
xhrFields: {
withCredentials: true
},
error: function(XMLHttpRequest, textStatus, errorThrown) { ajaxError(XMLHttpRequest, textStatus, errorThrown); },
success: function(xml) { DoSomething(xml); }
});
方法:加上红色标注部分
参考:https://stackoverflow.com/questions/1002179/how-can-i-pass-windows-authentication-to-webservice-using-jquery
winform调用:
var service=new xxxxService();
service.Credentials = System.NET.CredentialCache.DefaultCredentials;
From:http://www.cnblogs.com/xuejianxiyang/p/7337761.html
作者:xuejianxiyang
出处:http://xuejianxiyang.cnblogs.com
关于作者:Heaven helps those who help themselves.
本文版权归原作者和博客园共有,欢迎转载,但未经原作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。