HttpClient SendAsync

 static async void HttpClientSendAsync()
        {
            var client = new HttpClient(new HttpClientHandler { UseProxy = false });
            var request = new HttpRequestMessage(HttpMethod.Post, "http://www.albahari.com/EchoPost.aspx");
            request.Content = new StringContent("This is a test!");
            HttpResponseMessage response = await client.SendAsync(request);
            response.EnsureSuccessStatusCode();
            string result = await response.Content.ReadAsStringAsync();
            Console.WriteLine(result);
        }

 

posted @ 2020-06-09 12:03  FredGrit  阅读(1098)  评论(0编辑  收藏  举报