You are right that this has long since been implemented in .NET Core.
At the time of writing (September 2019), the project.json
file of NuGet 3.x+ has been superseded by PackageReference
(as explained at https://docs.microsoft.com/en-us/nuget/archive/project-json).
To get access to the *Async
methods of the HttpClient
class, your .csproj
file must be correctly configured.
Open your .csproj
file in a plain text editor, and make sure the first line is
<Project Sdk="Microsoft.NET.Sdk.Web">
(as pointed out at https://docs.microsoft.com/en-us/dotnet/core/tools/project-json-to-csproj#the-csproj-format).
To get access to the *Async
methods of the HttpClient
class, you also need to have the correct package reference in your .csproj
file, like so:
<ItemGroup>
<!-- ... -->
<PackageReference Include="Microsoft.AspNetCore.App" />
<!-- ... -->
</ItemGroup>
(See https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#adding-a-packagereference. Also: We recommend applications targeting ASP.NET Core 2.1 and later use the Microsoft.AspNetCore.App metapackage, https://docs.microsoft.com/en-us/aspnet/core/fundamentals/metapackage)
Methods such as PostAsJsonAsync
, ReadAsAsync
, PutAsJsonAsync
and DeleteAsync
should now work out of the box. (No using directive needed.)
Update: The PackageReference tag is no longer needed in .NET Core 3.0.