I am downloading a resource from web using HttpClient. The response message contains the Etag header, but when I try to access it via HttpResponseMessage.Headers.ETag property I keep getting null.
However, when I get the value using HttpResponseMessage.Headers.GetValues("ETag") I can see the value is present.
var etag1 = message.Headers.GetValues("ETag").FirstOrDefault();
// etag1 will be: "1;3;74778488-1a5a-4c2c-89e9-ff63532f0e7b;634797546688370000;26773"
var etag2 = message.Headers.ETag;
// This one is always null :(
stefando
0 Points
1 Post
HttpResponseMessage.Headers.Etag is null, but the header is present.
Aug 05, 2012 01:24 PM|LINK
Hello,
I am downloading a resource from web using HttpClient. The response message contains the Etag header, but when I try to access it via HttpResponseMessage.Headers.ETag property I keep getting null.
However, when I get the value using HttpResponseMessage.Headers.GetValues("ETag") I can see the value is present.
var etag1 = message.Headers.GetValues("ETag").FirstOrDefault(); // etag1 will be: "1;3;74778488-1a5a-4c2c-89e9-ff63532f0e7b;634797546688370000;26773" var etag2 = message.Headers.ETag; // This one is always null :(---
From fiddler:
---
Is something wrong with the ETag from the server or is it a bug?
Thanks, Stefan
HttpClient