Как я сохраняю логин с помощью httpwebrequeste?
я пытаюсь войти на сайт с помощью Httpweprequeste и я sucuss login
проблема когда я пытаюсь перейти на другой url а затем попросить меня снова войти в систему
и это мой код, в чем проблема ???
и это мой код
Что я уже пробовал:
CookieContainer cook = new CookieContainer(); string data = "act=login&accesskey=&si_user=a7mad-bas%40hotmail.com&si_pass=1236987412&si_stay=1&x=14&y=32"; Encoding enc = new UTF8Encoding(); byte[] postdata = enc.GetBytes(data); HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://[site].com/en/account/"); req.Method = "GET"; req.KeepAlive = true; req.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:43.0) Gecko/20100101 Firefox/43.0"; req.ContentType = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; req.CookieContainer=cook ; logincook = cook; HttpWebResponse res = (HttpWebResponse)req.GetResponse(); foreach (Cookie c in res.Cookies) { cook.Add(c); } logincook = cook; StreamReader sr = new StreamReader(res.GetResponseStream()); string x = sr.ReadToEnd(); richTextBox1.Text = x; //res.Close(); //post Method req = WebRequest.Create("http://[site].com/en/account/") as HttpWebRequest; req.Method = "POST"; req.KeepAlive = true; req.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:43.0) Gecko/20100101 Firefox/43.0"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = postdata.Length; cook= req.CookieContainer ; logincook = cook; Stream wr = req.GetRequestStream(); wr.Write(postdata, 0, postdata.Length); res = req.GetResponse() as HttpWebResponse; foreach (Cookie c in res.Cookies) { cook.Add(res.Cookies); } logincook = cook; sr = new StreamReader( res.GetResponseStream()); x = sr.ReadToEnd(); richTextBox2.Text = x; //MessageBox.Show(logincook.Count.ToString()); req = WebRequest.Create("http://[site].com/en/account/") as HttpWebRequest; req.Method = "GET"; req.KeepAlive = true; req.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:43.0) Gecko/20100101 Firefox/43.0"; req.ContentType = "application/x-www-form-urlencoded"; // req.ContentLength = postdata.Length; req.CookieContainer = cook; logincook = cook;