Windows phone 8.1 httpClient and session cookies

2019-09-06 07:06发布

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条回答
冷血范
2楼-- · 2019-09-06 07:38

Use the HttpMessageHandlers cookie container:

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

            var client = new HttpClient(handler);
查看更多
登录 后发表回答