Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the PostAsJsonAsync method in ASP.NET Core?

I was looking for the PostAsJsonAsync() extension method in ASP.NET Core. Based on this article, it's available in the Microsoft.AspNet.WebApi.Client assembly.

I had thought Microsoft had changed all of the assembly names from Microsoft.AspNet to Microsoft.AspNetCore to be more specific to .NET Core, however, and yet I cannot find an Microsoft.AspNetCore.WebApi.Client assembly.

Where is the PostAsJsonAsync() extension method in ASP.NET Core?

like image 536
LP13 Avatar asked Oct 13 '16 17:10

LP13


People also ask

What is PostAsJsonAsync?

PostAsJsonAsync<T>(HttpClient, Uri, T) Sends a POST request as an asynchronous operation to the specified Uri with the given value serialized as JSON. PostAsJsonAsync<T>(HttpClient, Uri, T, CancellationToken) Sends a POST request as an asynchronous operation to the specified Uri with the given value serialized as JSON.

Which method is not part of HttpClient?

HttpClient' does not contain a definition for 'PostAsJsonAsync' and No extension method 'PostAsJsonAsync' accepting a first argument of type 'System.

What is System Net HTTP?

Provides a programming interface for modern HTTP applications, including HTTP client components that allow applications to consume web services over HTTP and HTTP components that can be used by both clients and servers for parsing HTTP headers.


1 Answers

It comes as part of the library Microsoft.AspNet.WebApi.Client https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Client/

like image 177
Oliver Avatar answered Sep 23 '22 21:09

Oliver