vendredi 19 février 2016

HttpWebRequest dosent get response

When i try to load "https://web.com/forum" i dont get response, this url dosent need login to load. With the browser i only have to copy the url and it works fine without previous session.

When i try to load other url like "https://web.com" it works but "https://web.com/forum" dosent work. why?

HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://web.com/forum");
            CookieContainer cookieJar = new CookieContainer();
            req.CookieContainer = cookieJar;
            req.Referer = "https://web.com/forum";
            req.Method = "GET";
            req.Host = "web.com";
            req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
            req.ContentType = "application/x-www-form-urlencoded";
            req.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0";
            req.Proxy = null;

            using (HttpWebResponse response = (HttpWebResponse)req.GetResponse())
            {
                using (Stream responseStream = response.GetResponseStream())
                {
                    using (StreamReader sr = new StreamReader(responseStream))
                    {
                        respuesta = sr.ReadToEnd();
                    }
                }
            }

            MessageBox.Show(respuesta);

What's the problem here?.

I have tried also to remove referer, contentype, useragent... and other headers without success.

Thanks.




Aucun commentaire:

Enregistrer un commentaire