using System.Text; using Newtonsoft.Json; namespace Common.Util; /// /// http工具类 /// public static class HttpUtil { private static readonly HttpClient httpClient = new HttpClient(); public static readonly string MAIN_UER = "http://localhost:5034/"; /// /// 发送post请求 /// /// /// /// public static async void SendPostRequest(T data, string url) { string jsonStr = JsonConvert.SerializeObject(data); var content = new StringContent(jsonStr, Encoding.UTF8, "application/json"); try { HttpResponseMessage response = await httpClient.PostAsync(url, content); if (response.IsSuccessStatusCode) { await response.Content.ReadAsStringAsync(); } } catch (Exception e) { } } }