当前位置: 代码迷 >> Web Service >> HttpWebRequest.GetResponse()是自动在响应完成后调用吗?该怎么处理
  详细解决方案

HttpWebRequest.GetResponse()是自动在响应完成后调用吗?该怎么处理

热度:631   发布时间:2012-02-14 19:19:19.0
HttpWebRequest.GetResponse()是自动在响应完成后调用吗??
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(reqUrl);

request.GetResponse()是自动等待在响应完成后调用吗???还是响应还未完成就调出空的HttpWebResponse??




C# code
string PostData = Session["QQ"] + ";00;" + num + ";" + Session["LoginKey"] + ";";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(reqUrl);
request.Method = "POST";
byte[] bytes = Encoding.GetEncoding("GB2312").GetBytes(PostData);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = bytes.Length;     
Stream sr = request.GetRequestStream();
sr.Write(bytes, 0, bytes.Length);
sr.Dispose();
WebResponse response = request.GetResponse();


上面这段代码,HttpWebRequest什么时候发起的??




------解决方案--------------------
这是同步方法...跟你在浏览器里打开一个网页一样的,没下载完就一直阻塞直到下载完成或超时或捕获异常...
------解决方案--------------------
有网页请求就会进入的
  相关解决方案