I am trying to get automatically login into a website using POST method and everything seem to work fine except that my HttPWebResponse method conveniently skips a cookie that is marked as HttpOnly. Is there any way I can read it.
public CookieContainer _cookies = new CookieContainer();
down in the code I have
request.CookieContainer = _cookies;
I have read that when using CookieContainer I should not worry about reading the HttpOnly cookies as they are handled atomically. But apparently this is not the case. Using fiddler I do see that I get the 4 cookies but response.Cookies size if 3 and using the same code gets the next request rejected. Please help!!
Full code is as follows:
HttpWebRequest request = CreateRequest(uri);
request.Method = "POST";
request.GetRequestStream().Write(data, 0, data.Length);
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
return DecodeResponse(response);
DecodeResponse works as follows
foreach (System.Net.Cookie cookie in response.Cookies)
{
Console.WriteLine("Cookie:");
Console.WriteLine(cookie.HttpOnly);
_cookies.Add(new Uri(response.ResponseUri.GetLeftPart(UriPartial.Authority)), cookie);
}