Hi!
I can't get my head around this (login) problem: 1) I post some data 2) Server reacts and generate response with some cookies in headers (Set-Cookie) 3) I want to store that cookies so I can later use them to generate more requests
My C# code looks like this:
byte[] buffer = Encoding.ASCII.GetBytes(data_to_post);
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(url);
WebReq.Method = "POST";
WebReq.ContentType = "application/x-www-form-urlencoded";
WebReq.ContentLength = buffer.Length;
Stream PostData = WebReq.GetRequestStream();
PostData.Write(buffer, 0, buffer.Length);
PostData.Close();
HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
Stream Answer = WebResp.GetResponseStream();
StreamReader _Answer = new StreamReader(Answer);
WebResp.Close(); // I want cookies here! But there is no cookies :(
Thing is that WebResp does have the "Set-Cookie" header with values. Before I will run and parse headers I wonder why Cookies object is not propagated (0 cookies) and filled with values from header.
Anyone have idea ?