我正在使用VS2010+ .NET 4.0+ System.Net.Http(来自Nuget).
由于我无法理解的原因,我收到的会话cookie HttpResponseMessage不会自动保存在HttpClient CookieContainer.这是我的代码的样子:
CookieContainer cookies = new CookieContainer();
HttpClientHandler handler = new HttpClientHandler();
handler.CookieContainer = cookies;
HttpClient client = new HttpClient(handler);
Uri site = new Uri("https://www.mywebsite.com");
var response1 = client.SendAsync(new HttpRequestMessage(HttpMethod.Get,site)).Result;
Run Code Online (Sandbox Code Playgroud)
我可以在响应头中看到我有以下内容:
Set-Cookie: JSESSIONID=FC8110E434C2C6DAB78B4E335024A639; Path=/member; Secure
Run Code Online (Sandbox Code Playgroud)
但是我的cookie容器仍然是空的...为什么?
我确定它已经存在于某个地方,只是找不到它.