I triying to get cookies from a URL. I test with anothers URLs and works fine: I can get the cookies, but with my url doesn't return the cookie. The code:
using (var client = new HttpClient())
{
var response = client.GetAsync("http://192.168.5.230:5050/users/session").Result;
if (response.IsSuccessStatusCode)
{
var responseContent = response.Content;
// by calling .Result you are synchronously reading the result
string responseString = responseContent.ReadAsStringAsync().Result;
MessageBox.Show(responseString);
IEnumerable<string> cookieHeader;
response.Headers.TryGetValues("set-cookie", out cookieHeader);
MessageBox.Show(cookieHeader.Last().ToString()); // THIS LINE RETURN NULL
}
}
This line returns null:
MessageBox.Show(cookieHeader.Last().ToString());
I get the url by curl: screenshot here and returns a cookie.
I thought that the problem was the capital case of the "set-cookie" but in the code is exactly equal to the http response.
What can be the problem?