Câu hỏi được gắn thẻ «httpcontent»

6
HTTPContent.ReadAsAsync ở đâu?
Tôi thấy hàng tấn ví dụ trên web sử dụng HttpClientđối tượng mới (như một phần của API Web mới) cần có HttpContent.ReadAsAsync<T>phương thức. Tuy nhiên, MSDN không đề cập đến phương pháp này và IntelliSense cũng không tìm thấy nó. Nó đã đi đâu và làm thế nào để …

2
Làm cách nào để thiết lập HTTPContent cho tham số thứ hai của HTTPClient PostAsync?
public static async Task<string> GetData(string url, string data) { UriBuilder fullUri = new UriBuilder(url); if (!string.IsNullOrEmpty(data)) fullUri.Query = data; HttpClient client = new HttpClient(); HttpResponseMessage response = await client.PostAsync(new Uri(url), /*expects HttpContent*/); response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); return responseBody; } Các PostAsynctham số khác cần …
Khi sử dụng trang web của chúng tôi, bạn xác nhận rằng bạn đã đọc và hiểu Chính sách cookie và Chính sách bảo mật của chúng tôi.
Licensed under cc by-sa 3.0 with attribution required.