'System.Net.Http.HttpContent' does not contain a definition for 'ReadAsAsync' and no extension method
Solution 1:
After a long struggle, I found the solution.
Solution: Add a reference to System.Net.Http.Formatting.dll
. This assembly is also available in the C:\Program Files\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies folder.
The method ReadAsAsync
is an extension method declared in the class HttpContentExtensions
, which is in the namespace System.Net.Http
in the library System.Net.Http.Formatting
.
Reflector came to rescue!
Solution 2:
Make sure that you have installed the correct NuGet package
in your console application:
<package id="Microsoft.AspNet.WebApi.Client" version="4.0.20710.0" />
and that you are targeting at least .NET 4.0.
This being said, your GetAllFoos
function is defined to return an IEnumerable<Prospect>
whereas in your ReadAsAsync
method you are passing IEnumerable<Foo>
which obviously are not compatible types.
Install-Package Microsoft.AspNet.WebApi.Client