ASP.NET POST方式提交数据

发表于:2007-06-30来源:作者:点击数: 标签:
string url = 网址; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); string s = 要提交的数据; byte[] requestBytes = System.Text.Encoding.ASCII.GetBytes (LoginInfo); req.Method = POST; req.ContentType = application/x-www-form-urle
string url = "网址";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
string s = "要提交的数据";
byte[] requestBytes = System.Text.Encoding.ASCII.GetBytes (LoginInfo);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = requestBytes.Length;
Stream requestStream = req.GetRequestStream();
requestStream.Write(requestBytes,0,requestBytes.Length);
requestStream.Close();

HttpWebResponse res = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.Default);
string backstr = sr.ReadToEnd();
Response.Write(line);
sr.Close();
res.Close();


原文转自:http://www.ltesting.net