[Angular]:自定义标头未发送/未发送到Web API

时间:2018-07-24 10:39:06

标签: angular http httprequest

我目前正在使用ASP.NET Web API后端开发Angular 6应用程序。我正在尝试向我的网络api发送登录POST请求(请参见下面的代码)

let headers = new HttpHeaders();
headers.append('Content-Type', 'application/x-www-form-urlencoded');
headers.append('client_id', this.clientapphelper.getClientApp());

return this.client
    .post(
        this.apiurlhelper.GetApiUrl() + "token?",
        "grant_type=password&username=" + account.Username + "&password=" + account.Password,
        {headers: headers}
    );

现在,当我单击“提交”时,它会命中服务器,但看不到发送的 client_id 标头。我在使用Xamarin.Forms的移动应用程序中进行了尝试,并且可以正常工作。有什么想法吗?

我也尝试使用 HttpInterceptor ,但还是没有运气。

0 个答案:

没有答案
相关问题