Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AngularJS标头从Webapi返回500个内部服务器错误_Angularjs_Rest_Asp.net Web Api - Fatal编程技术网

AngularJS标头从Webapi返回500个内部服务器错误

AngularJS标头从Webapi返回500个内部服务器错误,angularjs,rest,asp.net-web-api,Angularjs,Rest,Asp.net Web Api,我正在尝试从angularjs应用程序向webapi post方法传递一个自定义头。但是webapi似乎没有捕获返回null到请求的头信息 我有 $http.defaults.headers.common.Authorization = "xasdfYer3444"; 在app.js的run方法中 请求如下 getAuthInfo: function (username, password,demographics) { var dataObj= {username:usern

我正在尝试从angularjs应用程序向webapi post方法传递一个自定义头。但是webapi似乎没有捕获返回null到请求的头信息

我有

$http.defaults.headers.common.Authorization = "xasdfYer3444"; 
在app.js的run方法中

请求如下

   getAuthInfo: function (username, password,demographics) { 
   var dataObj= {username:username,password:password};  
   var getservice = $resource(baselocation + "api/account", null);
   return  getservice.save(dataObj);
在web api中,我有

public IHttpActionResult index(HttpRequestMessage req,AccountParams acct)
{

     _accountinfo.request = req;
     return Ok(_accountinfo);

}

它返回500个内部服务器错误。有人能找出我遗漏了什么吗?谢谢。

500内部服务器错误意味着api方面有问题,您必须调试api代码。请在开发人员控制台中使用postmancheck尝试您的api,在请求标头中,授权标头正在发送。使用postman,我将标头取回,但不适用于angular js代码。500内部服务器错误意味着api方面有问题,您必须调试api代码。请在开发人员控制台中使用postmancheck尝试您的api,在请求标头中,授权标头正在发送。我使用postman返回标头,但不适用于angular js代码。