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什么时候发起的??
------解决方案--------------------
这是同步方法...跟你在浏览器里打开一个网页一样的,没下载完就一直阻塞直到下载完成或超时或捕获异常...
------解决方案--------------------
有网页请求就会进入的