模拟注册post问题(GetRequestStream后必须要GetResponse)
//模拟注册
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://login.sina.com.cn/signup/signup1.php");
request.CookieContainer = cookies;
request.Method = "POST";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
request.Referer = "http://login.sina.com.cn/signup/signup.php";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postData.Length;
Stream myRequestStream = request.GetRequestStream();
using (StreamWriter myStreamWriter = new StreamWriter(myRequestStream, Encoding.GetEncoding("gb2312")))
{
myStreamWriter.Write(postData);
}
myRequestStream.Close();
WebResponse response = request.GetResponse();//这个不能省略,否则发生意外错误
response.Close();
//模拟注册 end