How to read HttpResponseMessage content as text

后端 未结 3 2122
攒了一身酷
攒了一身酷 2021-01-01 09:00

I\'m using HttpResponseMessage class as a response from an AJAX call which is returning JSON data from a service. When I pause execution after the AJAX call comes back from

3条回答
  •  醉梦人生
    2021-01-01 09:19

    You can you ReadAsStringAsync() method

    var result = await response.Content.ReadAsStringAsync();
    

    We need to use await because we are using ReadAsStringAsync() which return task.

提交回复
热议问题