ServiceStack JsonServiceClient - 未发送自定义 HTTP 标头 [英] ServiceStack JsonServiceClient - Custom HTTP Headers not sent
本文介绍了ServiceStack JsonServiceClient - 未发送自定义 HTTP 标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 JsonServiceClient 发送自定义 HTTP 标头,但从未在查询中发送标头.
I'm trying to send custom HTTP Headers with a JsonServiceClient but headers are never sent in the query.
我正在使用:
JsonServiceClient client = new JsonServiceClient (baseUri);
client.Headers.Add ("X-Parse-Application-Id", "XXXXXX");
client.Headers.Add ("X-Parse-REST-API-Key", "XXXXXX");
有什么想法吗?
推荐答案
您还没有提出请求.在此处添加标头提出请求.
You haven't made a request yet. The Headers get added here when you make a request.
另一种添加标头的方法是使用请求过滤器,例如:
An alternative way to add headers is to use the Request filters, e.g:
client.RequestFilter = httpReq => {
httpReq.Headers.Add ("X-Parse-Application-Id", "XXXXXX");
httpReq.Headers.Add ("X-Parse-REST-API-Key", "XXXXXX");
};
有效地做同样的事情.
这篇关于ServiceStack JsonServiceClient - 未发送自定义 HTTP 标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文