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

Neil198 2011-02-17 06:17:36

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();这一步就超时呢?
...全文
186 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Neil198 2011-03-31
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 wuyq11 的回复:]
request = (HttpWebRequest)WebRequest.Create(LoginUrl);request.TimeOut..
request.Method = "POST";
request.Referer = "http://www.renren.com/SysHome.do";
……
[/Quote]
有什么区别么
wuyq11 2011-02-17
  • 打赏
  • 举报
回复

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

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧