唐朝程序员

我来自唐朝

有关http post的问题

string postData = "uUsername=avoid&uPassword=123456";
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] data = encoding.GetBytes(postData);

request = (HttpWebRequest)WebRequest.Create(sUrl);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
Stream newStream = request.GetRequestStream();
newStream.Write(data, 0, data.Length);

newStream.Close();

request.CookieContainer = cc;

response = (HttpWebResponse)request.GetResponse();
cc.Add(response.Cookies);
stream = response.GetResponseStream();
sHtml = new StreamReader(stream, System.Text.Encoding.Default).ReadToEnd();
//不好意思,贴错了.晕啊,还不让连续发
private CookieContainer cc = new CookieContainer();

posted on 2006-08-16 21:06  唐朝程序员  阅读(262)  评论(2编辑  收藏  举报

导航