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

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

问题描述

我目前正在尝试使用 .NET Core 和 MediaTypeFormatters 中的 HttpClient 进行一些 JSON 格式设置.特别是函数ReadAsAsync(..., MediaTypeFormatter, ...)"(https://msdn.microsoft.com/de-de/library/system.net.http.httpcontentextensions.readasasync(v=vs.118).aspx) 在 .NET Framework 的 HttpContent-Class 中可用非常有帮助.据我了解,它可以在 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 issue:

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天全站免登陆