我有一个角度服务,消耗基于.NET的WEB API服务的资源 .
我正在使用Angular $http
和params对象将所需的参数传递给WEB API . 我得到了 401 Unauthorized error
. 但是,如果我使用 $resource
API,则此请求将通过 . 我无法找出问题,因为我有其他服务电话 $http
成功 .
这是代码
function getParts(lineCode,partNo){
return $resource(URLs.BASE + "/api/RPP/GetVehiclePart", { lineCode: lineCode, partNo: partNo }, {
query: { method: 'GET', withCredentials: true }
});
}
以上工作,但下面没有
function getParts(lineCode,partNo){
return $http({
method: 'GET',
url: URLs.BASE + "/api/Rpp/GetVehiclePart?lineCode="+lineCode+"&partNo="+partNo,
withCredentials: true
}).then(_successHandler, _errorHandler);
}