Post请求:

 1    string postData = "user=123&pass=456"; // 要发放的数据 
 2    byte[] byteArray = Encoding.UTF8.GetBytes(postData);
 3 
 4    HttpWebRequest objWebRequest = (HttpWebRequest)WebRequest.Create("http://www.abc.com/a.aspx");
 5    objWebRequest.Method = "POST";
 6    objWebRequest.ContentType = "application/x-www-form-urlencoded";
 7    objWebRequest.ContentLength = byteArray.Length;
 8    Stream newStream = objWebRequest.GetRequestStream();
 9    // Send the data. 
10    newStream.Write(byteArray, 0, byteArray.Length); //写入参数 
11    newStream.Close();
12 
13    HttpWebResponse response = (HttpWebResponse)objWebRequest.GetResponse();
14    StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.Default);
15    string textResponse = sr.ReadToEnd(); // 返回的数据

 

接收参数:string a= Request.Form["user"];

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2021-07-29
  • 2021-10-28
  • 2021-09-10
猜你喜欢
  • 2022-12-23
  • 2021-11-18
  • 2021-12-16
  • 2021-08-14
  • 2021-06-03
  • 2022-01-30
  • 2022-12-23
相关资源
相似解决方案