I do authorization in CMS Xenforo. First, with the help of a get request, I receive cookies, and then I send it in a POST request. Everything would be okay, but in the sniffer I do not see any cookies in the post-request, although I added it to the CookieContainer.
static CookieContainer Cookie = new CookieContainer(); public static void Get() { HttpWebRequest request = (HttpWebRequest) WebRequest.Create("https://xenforo.info/"); request.CookieContainer = new CookieContainer(); request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36"; HttpWebResponse response = (HttpWebResponse) request.GetResponse(); Cookie.Add(response.Cookies); } public static void Post() { Get(); var request = (HttpWebRequest) WebRequest.Create("http://xenforo.info/login/login"); request.CookieContainer = new CookieContainer(); request.CookieContainer = Cookie; var postData = "login=xxx"; postData += "®ister=0"; postData += "&password=xxx"; postData += "&cookie_check=1"; postData += "&redirect=%2F"; postData += "&_xfToken="; var data = Encoding.ASCII.GetBytes(postData); request.Referer = " https://xenforo.info/"; request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = data.Length; request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36"; using(var stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } var response = (HttpWebResponse) request.GetResponse(); var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); }