HttpClient PCL Cookies do not apply to requests

I am using the .NET HttpClient for PCL (2.2.15) for a shared library through Windows Phone 8, Windows 8 and .NET 4.5. However, I do not see cookies applied to requests.

I am setting up HttpClient and HttpClientHandler using the following code. HttpClient is a property of the wrapping class.

CookieContainer = new CookieContainer();

var handler = new HttpClientHandler
{
    AllowAutoRedirect = true,
    CookieContainer = CookieContainer,
    Credentials = client.CredentialCache,
    UseCookies = true,
    AutomaticDecompression = 
          DecompressionMethods.Deflate | DecompressionMethods.GZip
};

HttpClient = new HttpClient(handler, false);

Requests are sent using the following.

var response = await HttpClient.SendAsync(httpRequestMessage);

I can look at the CookieContainer on the handler when switching to Debug and see the CookieContainer for the domain I'm working with with the expected cookie.

The cookie has the following meanings:

  • Path = '/'
  • Domain = '.staging3.api.com'
  • Value = [authentication_id]
  • Name = 'API_AuthId'

The following query is approximately: https://staging3.api.com/api/v3/Items

cookie , CookieContainer.GetCookieHeader(requestUri) .

:

requestUri https://www.staging3.api.com/api/v3/Items, cookie CookieContainer.GetCookieHeader(requestUri)

+4

All Articles