从HttpResponseMessage中提取内容

Nic*_*aub 11 .net casting wcf-web-api

我正在收到一个类型的对象,System.Net.Http.HttpResponseMessage<List<T>>我该如何获得List<T>

我尝试转换内容属性并通过其value属性从content属性中获取值,但似乎没有任何效果.

谢谢您的帮助!

Ale*_*ler 15

您可以使用Content属性的.ReadAsAsync <List <T >>方法.

还请从这个答案中读取我的样本.

更新:这些扩展方法位于System.Net.Http.FormattingNuGet包Microsoft.AspNet.WebApi.Client内的命名空间中.