码迷,mamicode.com
首页 > Web开发 > 详细

用httpclient访问时,附带cookie信息

时间:2015-01-05 10:49:56      阅读:117      评论:0      收藏:0      [点我收藏+]

标签:

var url = "address";
var cookieContainer = new CookieContainer();
using (var handler = new HttpClientHandler() { CookieContainer = cookieContainer })
using (var client = new HttpClient(handler) { })
{
    cookieContainer.Add(new Uri("youdomain"), new Cookie("cookieName", "cookieValue"));
    var result = client.GetStringAsync(url).Result;
    return Content(result);
}

用httpclient访问时,附带cookie信息

标签:

原文地址:http://www.cnblogs.com/czcz1024/p/4202948.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!