本文共 919 字,大约阅读时间需要 3 分钟。
string strId = "guest"; string strPassword= "123456"; ASCIIEncoding encoding=new ASCIIEncoding(); string postData="userid="+strId; postData += ("&password="+strPassword); byte[] data = encoding.GetBytes(postData); // Prepare web request... HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://www.here.com/login.asp"); myRequest.Method = "POST"; myRequest.ContentType="application/x-www-form-urlencoded"; myRequest.ContentLength = data.Length; Stream newStream=myRequest.GetRequestStream(); // Send the data. newStream.Write(data,0,data.Length); newStream.Close(); // Get response HttpWebResponse myResponse=(HttpWebResponse)myRequest.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream(),Encoding.Default); string content = reader.ReadToEnd(); Console.WriteLine(content);