Created
November 16, 2017 19:45
-
-
Save stephenpatten/603e297865d879a8c0c15b47052f1f41 to your computer and use it in GitHub Desktop.
HttpClient Cookies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CookieContainer cookies = new CookieContainer(); | |
| HttpClientHandler handler = new HttpClientHandler(); | |
| handler.CookieContainer = cookies; | |
| HttpClient client = new HttpClient(handler); | |
| HttpResponseMessage response = client.GetAsync("http://google.com").Result; | |
| Uri uri = new Uri("http://google.com"); | |
| IEnumerable<Cookie> responseCookies = cookies.GetCookies(uri).Cast<Cookie>(); | |
| foreach (Cookie cookie in responseCookies) | |
| Console.WriteLine(cookie.Name + ": " + cookie.Value); | |
| Console.ReadLine(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment