Witam.
Mam problem z ciasteczkami w httpwebrequest.
Tutaj problem na pewno jest z ciasteczkami ponieważ kiedy ustawiam je ręcznie wszystko działa ok.
Logowanie:
CookieContainer cookie = new CookieContainer();
HttpWebRequest pobieranieciasteczke = (HttpWebRequest)WebRequest.Create("xxx");
pobieranieciasteczke.CookieContainer = cookie;
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "Username=" + login + "&Password=" + pass;
byte[] postDataBytes = encoding.GetBytes(postData);
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("xxx");
httpWebRequest.CookieContainer = cookie;
httpWebRequest.Method = "POST";
httpWebRequest.ContentType = "application/x-www-form-urlencoded";
httpWebRequest.ContentLength = postDataBytes.Length;
httpWebRequest.AllowAutoRedirect = false;
httpWebRequest.Referer = "xxx";
I sprawdzanie:
CookieContainer cookie = new CookieContainer();
HttpWebRequest pobieranieciasteczke = (HttpWebRequest)WebRequest.Create("xxx");
pobieranieciasteczke.CookieContainer = cookie;
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "send=test";
byte[] postDataBytes = encoding.GetBytes(postData);
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("xxx");
httpWebRequest.CookieContainer = cookie;
httpWebRequest.Method = "POST";
httpWebRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
httpWebRequest.ContentLength = postDataBytes.Length;
httpWebRequest.AllowAutoRedirect = false;
Niestety nie działa. Co robię źle?