110,533
社区成员
发帖
与我相关
我的任务
分享
private void button1_Click(object sender, EventArgs e)
{
Encoding encoding = Encoding.GetEncoding("utf-8");
string URL = "http://192.168.1.115/cccn/test_post.php";
string postData = "username=" + textBox1.Text.ToString() + "&password=" + textBox2.Text.ToString();
byte[] data = encoding.GetBytes(postData);
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(URL);
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded;charset=utf-8";
myRequest.ContentLength = data.Length;
Stream st = myRequest.GetRequestStream();
st.Write(data, 0, data.Length);
st.Close();
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
Stream receiveStream = myResponse.GetResponseStream();
StreamReader readStream = new StreamReader(receiveStream, encoding);
char[] read = new char[256];
int count = readStream.Read(read, 0, 256);
String str = null;
while (count > 0)
{
str += new string(read, 0, count);
count = readStream.Read(read, 0, 256);
}
myResponse.Close();
readStream.Close();
网页不显示,怎么回事啊