标签:class using string ons orm syn system tpc ada
using System.Net.Http; static void Main(string[] args) { var httpTask = Task<string>.Run<string>(() => { return MainAsync(); }); httpTask.Wait(); Console.WriteLine(httpTask.Result); Console.ReadLine(); } static async Task<string> MainAsync() { using (var client = new HttpClient()) { List<KeyValuePair<string, string>> kvpsList = new List<KeyValuePair<string, string>>(); kvpsList.Add(new KeyValuePair<string, string>("k1", "v1")); kvpsList.Add(new KeyValuePair<string, string>("k2", "v2")); var formContent = new FormUrlEncodedContent(kvpsList); var result = await client.PostAsync(url, formContent); string resultContent = await result.Content.ReadAsStringAsync(); return resultContent; } }
C# HttpClient PostAsync with parameters
标签:class using string ons orm syn system tpc ada
原文地址:https://www.cnblogs.com/Fred1987/p/12557113.html