.NET Core是否支持Microsoft.AspNet.WebApi.Client? [英] Is Microsoft.AspNet.WebApi.Client supported in .NET Core or not?

查看:49
本文介绍了.NET Core是否支持Microsoft.AspNet.WebApi.Client?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试使用.NET Core和MediaTypeFormatters中的HttpClient进行一些JSON格式化.尤其是功能"ReadAsAsync(...,MediaTypeFormatter,...)".( https:在.NET Framework中的HttpContent-Class中////msdn.microsoft.com/de-de/library/system.net.http.httpcontentextensions.readasasync(v=vs.118).aspx )会很有帮助.据我了解,可以在NuGet包Microsoft.AspNet.WebApi.Client中找到它,但由于.NET Core不支持它,因此我无法下载它.

I'm currently trying to do some JSON formatting using the HttpClient in .NET Core and MediaTypeFormatters. Especially the function "ReadAsAsync(..., MediaTypeFormatter, ...)" (https://msdn.microsoft.com/de-de/library/system.net.http.httpcontentextensions.readasasync(v=vs.118).aspx) which was available in .NET Framework in the HttpContent-Class would be very helpful. As far as I understood, it can be found in the NuGet package Microsoft.AspNet.WebApi.Client but I cannot download it because it is not supported in .NET Core.

尽管我已经读过,但应该是:

Though I have read, that it should be:

我知道可以使用Newtonsoft等进行格式化.

I know that it is possible to do the formatting using Newtonsoft and so on.

但是有人知道,是否有一天该包将再次在.NET Core中可用?我真的找不到任何信息...

But does someone know, if that package will be available in .NET Core some day again? I could not find any information really...

推荐答案

更新:

Microsoft.AspNet.WebApi.Client版本5.2.4已于2018-02-12发行.

Microsoft.AspNet.WebApi.Client version 5.2.4 was released on 2018-02-12.

感谢@ whitney-kew @jaquez

Thanks @whitney-kew @jaquez

该软件包现在与dotnetcore并不完全兼容.但是,有一种解决方法.您必须像下面一样编辑project.csproj:

The package is not fully compatible with dotnetcore now. However there's workaround for this. You have to edit project.csproj like below:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
   <TargetFramework>netstandard1.4</TargetFramework>
   <PackageTargetFallback>portable-net451+win8</PackageTargetFallback>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.3" />
    <PackageReference Include="System.Runtime.Serialization.Xml" Version="4.3.0-*" />
    <PackageReference Include="System.Xml.XmlSerializer" Version="4.3.0-*" />
  </ItemGroup> 
</Project>

有关详细信息,请参阅此github问题:

Please refer to this github issue for details:

https://github.com/aspnet/Home/issues/1558

我认为新的Microsoft.AspNet.WebApi.Client版本(5.2.4)应该可以解决此问题,但尚未发布,可能在2017年底.

I think the new Microsoft.AspNet.WebApi.Client version (5.2.4) should fix this, but it's not released yet, maybe in late 2017.

这篇关于.NET Core是否支持Microsoft.AspNet.WebApi.Client?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆