您的位置:首页 > 产品设计 > UI/UE

模拟注册post问题(GetRequestStream后必须要GetResponse)

2010-10-18 09:31 501 查看
//模拟注册
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐