zoukankan      html  css  js  c++  java
  • HTTP get、post请求

    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"];

  • 相关阅读:
    csp-s测试41 T2 影子
    模拟测试15 T3:rps (概率期望, 神*DP)
    考试沙币错误
    测试40
    水管局长 Lct
    测试32:chemistry
    测试35:抽卡
    模拟30,树
    考试策略&&模拟30经验总结:
    模拟测试28
  • 原文地址:https://www.cnblogs.com/mrzhoushare/p/5564336.html
Copyright © 2011-2022 走看看