HttpClient SendAsync
Posted fred1987
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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); }
以上是关于HttpClient SendAsync的主要内容,如果未能解决你的问题,请参考以下文章
尽管 Fiddler 显示收到了正确的响应,但 Blazor WASM 上的 HttpClient.SendAsync 返回空 HttpResponseMessage
HttpClient.SendAsync() 未将 JSON 作为字符串发送
从 HttpClient SendAsync 请求获取响应时出现无法解释的超时和延迟