HttpWebRequest dosent获得响应

时间:2016-02-19 20:33:31

标签: c# .net web httpwebrequest

当我尝试加载" https://web.com/forum"我没有得到回应,这个url dosent需要登录加载。使用浏览器我只需要复制网址,它没有以前的会话工作正常。

当我尝试加载其他网址时,例如" https://web.com"它有效,但" https://web.com/forum"有意义的工作。为什么呢?

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);

这里的问题是什么?。

我还试图删除referer,contentype,useragent ......和其他标题但没有成功。

感谢。

0 个答案:

没有答案
相关问题