Extract contents from HttpResponseMessage

Nicolás Straub picture Nicolás Straub · Dec 27, 2011 · Viewed 10.9k times · Source

I'm recieving an object of type System.Net.Http.HttpResponseMessage<List<T>>, how do I get the List<T>?

I tried casting the content property and getting a value from the content property via its value property but nothing seems to work.

Thanks for the help!

Answer

Alexander Zeitler picture Alexander Zeitler · Dec 27, 2011

You can use the .ReadAsAsync<List<T>> method of the Content property.

Please also read my sample from this answer.

Update: These extension methods are located in the System.Net.Http.Formatting namespace inside the NuGet Package Microsoft.AspNet.WebApi.Client.