.net 中HttpClient 携带cookie传输

            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;
原文地址:https://www.cnblogs.com/sjns/p/5331723.html