首页 > Web开发 > 详细

.net 中HttpClient 携带cookie传输

时间:2016-03-29 10:07:08      阅读:206      评论:0      收藏:0      [点我收藏+]

 

            CookieContainer cookieContainer = new CookieContainer();
            Cookie cookie = new Cookie("username", "username");
            cookie.Domain = Request.Url.Host;
            cookieContainer.Add(cookie);   // 加入Cookie
            HttpClientHandler httpClientHandler = new HttpClientHandler()
            {
                CookieContainer = cookieContainer,
                AllowAutoRedirect = true,
                UseCookies = true
            };
            HttpClient httpClient = new HttpClient(httpClientHandler);
            var resp = httpClient.GetAsync("http://localhost:8002/Public/Passport.aspx").Result;

 

.net 中HttpClient 携带cookie传输

原文:http://www.cnblogs.com/sjns/p/5331723.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!