How to get an specific header value from the HttpResponseMessage

前端 未结 7 1832
挽巷
挽巷 2020-12-16 09:17

I\'m making an HTTP call. My response contains a session code X-BB-SESSION in the header section of the HttpResponseMessage object. How do I get th

7条回答
  •  甜味超标
    2020-12-16 09:30

    You should be able to use the TryGetValues method.

    HttpHeaders headers = response.Headers;
    IEnumerable values;
    if (headers.TryGetValues("X-BB-SESSION", out values))
    {
      string session = values.First();
    }
    

提交回复
热议问题