日期:2014-05-17 浏览次数:20507 次
string url = "";
HttpWebRequest request = HttpWebRequest.Create(url) as HttpWebRequest;
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
Stream stream = request.GetRequestStream();
string name = "";
string strFormData = string.Format("name={0}", name);
byte[] buff = System.Text.Encoding.Default.GetBytes(strFormData);
stream.Write(buff, 0, buff.Length);
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
Stream streamRes = response.GetResponseStream();
StreamReader streamReader = new StreamReader(streamRes, System.Text.Encoding.Default);
string resultHtml = streamReader.ReadToEnd();
response.Close();
streamReader.Close();
string url = "";
string name = "";
HttpWebRequest request = HttpWebRequest.Create(url + "?name=" + name) as HttpWebRequest;
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
Stream streamRes = response.GetResponseStream();
StreamReader streamReader = new StreamReader(streamRes, System.Text.Encoding.Default);
string resultHtml = streamReader.ReadToEnd();
response.Close();
streamReader.Close();