title: How to get an specific header value from the HttpResponseMessage
body: <p>I'm making an HTTP call. My response contains a session code <code>X-BB-SESSION</code> in the header section of the <code>HttpResponseMessage</code> object. How do I get that specific header value?</p>
  
  <p>I am using a foreach statement to iterate through all the headers (<a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.web.http.headers.httpresponseheadercollection.aspx" rel="noreferrer">MSDN link</a>). However the compiler keeps saying that it cannot be done: </p>
  
  <pre><code>foreach statement cannot operate on variables of type
    System.net.http.headers.cachecontrolheadervalue because
    'System.net.http.headers.cachecontrolheadervalue' doesn't contain
    a public definition for 'GetEnumerator'
  </code></pre>
  
  <p>This is the code I'm trying:</p>
  
  <pre><code>//Connection code to BaasBox
  
  HttpResponseMessage response = await client.SendAsync(requestMessage, HttpCompletionOption.ResponseHeadersRead);
  if (response.IsSuccessStatusCode)
  {
      //get the headers
      HttpResponseHeaders responseHeadersCollection = response.Headers;
      foreach (var value in responseHeadersCollection.CacheControl)  --&gt; HERE
      {
          string sTemp = String.Format("CacheControl {0}={1}", value.Name, value.Value);
      } else
  {
      Console.WriteLine("X-BB-SESSION: NOT Found");
  }
  </code></pre>
  
  <p>The header content from where I'm trying to get the value (<code>X-BB-SESSION</code> value) is something like:</p>
  
  <pre><code>Access-Control-Allow-Origin: *    
  Access-Control-Allow-Headers: X-Requested-With    
  X-BB-SESSION: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  </code></pre>