var req = (HttpWebRequest)HttpWebRequest.Create("http://mydomain.com/myservice");
var resp = (HttpWebResponse)req.GetResponse();
var cookies = resp.Cookies;
Console.WriteLine("Cookie count: {0}", cookies.Count);
Output is:
Cookie count: 0
I can see using Charles that the call to my web service is returning cookies. Why don’t they show up in my response’s cookie collection?
Try creating a
CookieContainerin your request object to accomodate the cookies:From the Remarks section of the documentation for the
CookieContainerproperty: