首页 > 代码库 > 用httpclient访问时,附带cookie信息

用httpclient访问时,附带cookie信息

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信息