当前位置:编程学习 > C#/ASP.NET >>

httpwebrequest模拟人人网登陆POST超时的问题


static string HostUrl = "http://www.renren.com/SysHome.do";//xiaonei主页
        static string LoginUrl = "http://www.renren.com/PLogin.do";//login主页
        static CookieContainer cookecn = new CookieContainer();
        static string email = "用户名";
        static string pwd = "密码";
        static string fisrtgethost = string.Empty;
        static string Cookiesstr = string.Empty;
HttpWebRequest request = null;
            HttpWebResponse response = null;
            try
            {
                request = (HttpWebRequest)WebRequest.Create(LoginUrl);
                request.Method = "POST";
                request.Referer = "http://www.renren.com/SysHome.do";
                request.ContentType = "application/x-www-form-urlencoded";
                request.AllowAutoRedirect = false;
                byte[] postdatabtyes = Encoding.UTF8.GetBytes(postdata);
                request.ContentLength = postdatabtyes.Length;
                request.CookieContainer = cookecn;
                request.KeepAlive = true;
                Stream requeststream = request.GetRequestStream();
                requeststream.Write(postdatabtyes, 0, postdatabtyes.Length);
                requeststream.Close();
                response = (HttpWebResponse)request.GetResponse();
......


为什么执行到response = (HttpWebResponse)request.GetResponse();这一步就超时呢? --------------------编程问答--------------------
request = (HttpWebRequest)WebRequest.Create(LoginUrl);request.TimeOut..
                request.Method = "POST";
                request.Referer = "http://www.renren.com/SysHome.do";
                request.ContentType = "application/x-www-form-urlencoded";
                request.AllowAutoRedirect = false;
                byte[] postdatabtyes = Encoding.UTF8.GetBytes(postdata);
                request.ContentLength = postdatabtyes.Length;
                request.CookieContainer = cookecn;
                request.KeepAlive = true;
                Stream requeststream = request.GetRequestStream();
                requeststream.Write(postdatabtyes, 0, postdatabtyes.Length);
                requeststream.Close();
--------------------编程问答--------------------
引用 1 楼 wuyq11 的回复:
request = (HttpWebRequest)WebRequest.Create(LoginUrl);request.TimeOut..
                request.Method = "POST";
                request.Referer = "http://www.renren.com/SysHome.do";
              ……

有什么区别么
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,