Windows Phone 8.1 httpClient和会话Cookie [英] Windows phone 8.1 httpClient and session cookies
本文介绍了Windows Phone 8.1 httpClient和会话Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
httpClient是否存储并重新发送会话cookie?
Does httpClient store and resend session cookies?
由于使用PostAsync,我正在连接到服务器(并对其进行调试),并且在登录后检查状态时不存在会话.
Because using PostAsync I am connecting to (and debugging) a server and after login when I check my status the sessions doesn't exists.
如果是真的,我该如何告诉HttpClient使用Cookie?我一直在寻找这个问题,只发现有人问如何操作cookie,我只想保留会话cookie.
And if it is true, how can I say to HttpClient to use cookies? I have been looking for this question and I am only finding people asking how to manipulate cookies, I only want to mantain session cookies.
谢谢.
我使用的代码
HttpClient httpClient = new HttpClient();
HttpResponseMessage httpResp = await httpClient.PostAsync(url, new FormUrlEncodedContent(parameters));
推荐答案
使用HttpMessageHandlers cookie容器:
Use the HttpMessageHandlers cookie container:
var handler = new HttpClientHandler();
var cookieContainer = handler.CookieContainer;
var client = new HttpClient(handler);
这篇关于Windows Phone 8.1 httpClient和会话Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文