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!
Several months ago, Microsoft decided to change up the HttpResponseMessage class. Before, you could simply pass a data type into the constructor, and then return the message with that data, but not anymore. Now, you need to use the Content property to set the content of the message.
A HttpResponseMessage allows us to work with the HTTP protocol (for example, with the headers property) and unifies our return type. In simple words an HttpResponseMessage is a way of returning a message/data from your action.
HttpResponseMessage. If the action returns an HttpResponseMessage, Web API converts the return value directly into an HTTP response message, using the properties of the HttpResponseMessage object to populate the response. This option gives you a lot of control over the response message.
This is no longer possible. Check this out: http://aspnetwebstack.codeplex.com/discussions/350492
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With