ServiceStack JsonServiceClient - 未发送自定义HTTP标头

时间:2013-07-12 11:19:25

标签: servicestack

我尝试使用JsonServiceClient发送自定义HTTP标头,但查询中永远不会发送标头。

我正在使用:

JsonServiceClient client = new JsonServiceClient (baseUri);
client.Headers.Add ("X-Parse-Application-Id", "XXXXXX");
client.Headers.Add ("X-Parse-REST-API-Key", "XXXXXX");

有什么想法吗?

2 个答案:

答案 0 :(得分:8)

您尚未提出请求。提出请求时Headers get added here

添加标头的另一种方法是使用请求过滤器,例如:

client.RequestFilter = httpReq => {
    httpReq.Headers.Add ("X-Parse-Application-Id", "XXXXXX");
    httpReq.Headers.Add ("X-Parse-REST-API-Key", "XXXXXX");
};

有效地做同样的事情。

答案 1 :(得分:0)

这是另一种方法。

_client.RequestFilter = httpReq => httpReq.Headers.Add("X-CUSTOM", "hello");
相关问题