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 Core 中 HttpClientFactory 如何解决 HttpClient 臭名昭著的问题
- c#.net与vb.net中读写Cookie的方法!
- 3分钟快速学会在ASP.NET Core MVC中如何使用Cookie
- 【ASP.NET Web API教程】5.5 ASP.NET Web API中的HTTP Cookie
- ASP.NET中的两个Cookie类:HttpCookie类与Cookie类
- .net 中HttpClient 携带cookie传输
- ASP.NET中Cookie的使用方法
- ASP.NET Core SignalR中的流式传输深入讲解
- .NET Core中HttpClient的正确打开方式
- asp.net中对象的序列化,方便网络传输