zoukankan      html  css  js  c++  java
  • 【.Net】HttpClient 的使用

     1     class Program
     2     {
     3         public static HttpClient Client;
     4         static HttpResponseMessage response;
     5 
     6         static void Main(string[] args)
     7         {
     8 
     9 
    10             var httpClient = new HttpClient();
    11             string url = "http://127.0.0.1/Manager/Login.aspx";
    12             List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>();
    13             paramList.Add(new KeyValuePair<string, string>("Username", "123"));
    14             paramList.Add(new KeyValuePair<string, string>("Password", "456"));
    15             response = httpClient.PostAsync(new Uri(url), new FormUrlEncodedContent(paramList)).Result;
    16             string result = response.Content.ReadAsStringAsync().Result;
    17    
    18 
    19             paramList = new List<KeyValuePair<string, string>>();
    20             paramList.Add(new KeyValuePair<string, string>("PageIndex", "0"));
    21             paramList.Add(new KeyValuePair<string, string>("PageSize", "10"));
    22 
    23             url = "http://127.0.0.1/News/NewsList.aspx";
    24             response = httpClient.PostAsync(new Uri(url), new FormUrlEncodedContent(paramList)).Result;
    25             result = response.Content.ReadAsStringAsync().Result;
    26             Console.WriteLine(result);
    27             Console.Read();
    28 
    29           
    30 
    31         
    32         }
    33 
    34     }

    .net framework 4.5 及其以上 

  • 相关阅读:
    输入函数
    pe结构讲解
    pe结构讲解
    小甲鱼pe结构讲解
    pe结构讲解
    pe结构讲解
    YUI3学习笔记 ( 7 )
    [转载 css]用CSS调整scrollbar(滚动条)的配色
    [转载 js]一次性解决png在i6下的透明问题(包括做为img和背景的两种情况)
    YUI3学习笔记 ( 7 )
  • 原文地址:https://www.cnblogs.com/yanglang/p/7212216.html
Copyright © 2011-2022 走看看