HttpClient PCL Cookie未应用于请求

我正在使用.NET HttpClient for PCL(2.2.15)来跨Windows Phone 8,Windows 8和.NET 4.5的公共库。 但是,我没有看到cookie被应用于请求。

我正在使用以下代码设置HttpClient和HttpClientHandler。 HttpClient是包装类的属性。

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); 

使用以下内容发送请求。

 var response = await HttpClient.SendAsync(httpRequestMessage); 

当我在Debug中单步执行时,我能够查看处理程序上的CookieContainer,并且能够看到我正在使用预期cookie进行反对的域的CookieContainer。

Cookie具有以下值:

  • 路径=’/’
  • Domain =’。staging3.api.com’
  • 值= [authentication_id]
  • Name =’API_AuthId’

后续请求大致为: https://staging3.api.com/api/v3/Itemshttps://staging3.api.com/api/v3/Items

我也尝试过自己设置cookie,但CookieContainer.GetCookieHeader(requestUri)返回一个空字符串。

附加信息:

如果我将requestUri修改为https://www.staging3.api.com/api/v3/Items我可以从CookieContainer.GetCookieHeader(requestUri)获取cookie头