Windows phone 8.1 httpClient and session cookies

半腔热情 提交于 2019-12-11 20:17:33

问题


Does httpClient store and resend session cookies?

Because using PostAsync I am connecting to (and debugging) a server and after login when I check my status the sessions doesn't exists.

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.

Thank you.

The code I use

HttpClient httpClient = new HttpClient();
HttpResponseMessage httpResp = await httpClient.PostAsync(url, new FormUrlEncodedContent(parameters));

回答1:


Use the HttpMessageHandlers cookie container:

            var handler = new HttpClientHandler();
            var cookieContainer = handler.CookieContainer;

            var client = new HttpClient(handler);


来源:https://stackoverflow.com/questions/27672598/windows-phone-8-1-httpclient-and-session-cookies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!