使用HttpResponseMessage,GetAsynch存储标头键和值

时间:2016-08-05 00:35:42

标签: c# cookies header httpresponsemessage getasync

我有以下代码,我想在KeyValuepair类型的对象中存储标题的所有键和值(即cookie,会话ID等)。我怎么能做到这一点?

CookieContainer cookies = new CookieContainer();
        HttpClientHandler handler = new HttpClientHandler();
        handler.CookieContainer = cookies;

        HttpClient client = new HttpClient(handler);
        HttpResponseMessage response = client.GetAsync("http://google.com").Result;
        HttpHeaders headers = response.Headers;

我需要这些值,因为之后我将使用相同的cookie和sessionid发布到网站。

0 个答案:

没有答案