System.Net.Http与Microsoft.Net.Http的当前状态 [英] The current status of System.Net.Http vs. Microsoft.Net.Http

查看:162
本文介绍了System.Net.Http与Microsoft.Net.Http的当前状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对HttpClient的包装感到困惑.早些时候它作为Microsoft.Http.Net NuGet软件包的一部分分发,而System.Net.Http被认为是旧版.看起来现在相反了:针对所有平台都有一个新的System.Net.Http软件包,并且Microsoft.Net.Http已有一段时间没有更新,并且据Microsoft开发团队的人员说,将不推荐使用.

I am confused with packaging of HttpClient. Earlier it was distributed as a part of Microsoft.Http.Net NuGet package while System.Net.Http was considered legacy. Looks like now it's the opposite: there is a fresh System.Net.Http package for all platforms and Microsoft.Net.Http has not been updated in a while and according to folks at Microsoft development team is going to be deprecated.

然后的问题:

  • 我们可以用(最新的)System.Net.Http替换对Microsoft.Net.Http NuGet软件包的依赖吗?
  • 旧版.NET 4.0平台仍应使用Microsoft.Net.Http吗? 非Windows平台(iOS,Android)呢?新的System.Net.Http支持它们,但是我记得使用Microsoft.Net.Http时,我必须另外安装Microsoft.Bcl.BuildMicrosoft.Bcl才能使跨平台的东西正常工作. System.Net.Http不依赖于它们.可以跳过Bcl包吗?
  • System.Net.Http缺少一些Http扩展方法,例如SupportsPreAuthenticate,并且尝试调用这些方法会导致运行时错误(缺少方法).我们应该如何处理呢?
  • Can we replace dependencies on Microsoft.Net.Http NuGet package with (the newest) System.Net.Http?
  • Should legacy .NET 4.0 platform still use Microsoft.Net.Http? What about non-Windows platforms (iOS, Android)? The new System.Net.Http supports them, but I remember with Microsoft.Net.Http I had to install additionally Microsoft.Bcl.Build and Microsoft.Bcl in order to get cross-platform stuff to work. System.Net.Http doesn't depend on them. Can Bcl packages be skipped?
  • System.Net.Http lacks some Http extension methods, like SupportsPreAuthenticate, and an attempt to call these method results in runtime errors (missing method). How should we deal with this?

推荐答案

这已经有很长时间了,并且仍然令人困惑.我本人已经看到过此类消息传递,但截至目前,它似乎 System.Net.Http 是正确的选择,至少对于Windows平台上的.NET而言,并且没有外部依赖性.

This has been for a long time and continues to be confusing. I have seen such messaging myself but as of right now, it appears System.Net.Http is the correct choice, at least for .NET on the Windows platform and has no external dependencies.

对于.NET Core,尽管使用了 Microsoft.Net.Http 它确实需要 Microsoft.BCL .除非您遇到问题,否则我建议保持原有系统不变,尤其是因为这些名称空间似乎正在成为目标.

For .NET Core, I have used Microsoft.Net.Http although it does require Microsoft.BCL. Unless you are experiencing problems, I suggest leaving legacy systems as-is, especially since these namespaces seem to be moving targets.

如果这还不足以使您感到困惑,请从以下链接链接 HttpClient示例 System.Net.Http使用 Windows.Web.Http !该实现适用于Windows应用商店应用.

If that isn't confusing enough for you, the HttpClient Sample linked from System.Net.Http uses Windows.Web.Http! That implementation is for Windows Store apps.

也许明年这一切都会再次改变.

Perhaps next year this will all change again.

这篇关于System.Net.Http与Microsoft.Net.Http的当前状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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