标签:for tps 微软 form cli har ros asp iclient
使用HttpClient实现http请求是非常常见的方式,有一个HttpClient的拓展类HttpClientExtensions提供了更多的拓展方法,包括但不限于
PostAsJsonAsync
PostAsXmlAsync
PutAsJsonAsync
PutAsXmlAsync
.Net 4.5之前HttpClientExtensions在System.Net.Http.dll,从.Net 4.5开始HttpClientExtensions在System.Net.Http.Formatting.dll
查证来源:HttpClientExtensions Methods?(System.Net.Http) | Microsoft Docs
根据 json - HttpClient not supporting PostAsJsonAsync method C# - Stack Overflow 和 CS1061 ‘HttpClient‘ does not contain a definition for ‘PostAsJsonAsync‘ For asp.net core project · Issue #3849 · aspnet/AspNetCore.Docs可以得出以下3种解决办法。
Microsoft.AspNet.WebApi.Client
,NuGet Gallery | Microsoft.AspNet.WebApi.Client 5.2.7Microsoft.AspNet.WebApi.Client
依赖
.NETFramework 4.5
Newtonsoft.Json (>= 6.0.4)
.NETStandard 2.0
Newtonsoft.Json (>= 10.0.1)
Newtonsoft.Json.Bson (>= 1.0.1)
Portable Class Library (.NETFramework 4.5, .NETCore 4.5, WindowsPhone 8.0, WindowsPhone 8.1, WindowsPhoneApp 8.1)
Microsoft.Net.Http (>= 2.2.22)
Newtonsoft.Json (>= 6.0.4)
标签:for tps 微软 form cli har ros asp iclient
原文地址:https://www.cnblogs.com/AlienXu/p/where_is_HttpClientExtensions.html