在 .NET 中创建 REST 客户端时,WebClient 是否优于 HttpClient?

发布于 2024-12-28 20:03:35 字数 439 浏览 3 评论 0原文

我只是一般性地学习 WCF/REST。

然而,我有点困惑。我注意到,在 Visual Studio 2010 中,如果我使用在线模板并创建一个新的休息服务示例,我会得到一个使用 WebClient 的客户端,但是观看一些 .NET 3.5 屏幕截图(这就是我能找到的全部),我看到它们使用 HttpClient 但是它看起来 HttpClient 自从他们使用它以来已经发生了一些变化,但是当我进一步研究它时(此处)看起来 HttpClient 可能是更好的方法,因为它支持异步获取。

WCF 可能有点令人沮丧,因为它发展得如此之快,似乎几年前的博客/屏幕截图已经过时了。咩!

谢谢!

I am just learning WCF/REST in general.

I am however, a little confused. I noticed that in visual studio 2010 if I use the online template and create a new rest service sample I get a client that uses WebClient, however watching some .NET 3.5 screen casts (that's all I can find) I see them using HttpClient however it looks like HttpClient has changed a little since they used it but when I looked into it a little more (here) it looks like HttpClient might be the better way to go because it supports async get.

WCF can be a little frustrating because it is evolving so fast, it seems like a blog / screen cast a couple of years old is already outdated. Baa!

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

缱倦旧时光 2025-01-04 20:03:35

HttpClient 仍处于预览版 - http://msdn.microsoft.com/en-us/library/system.net.http.httpclient(v=vs.110).aspx

要么是您看到的,要么是某人的手写版本。

Webclient 到目前为止已经过尝试和测试。

WebClient 也具有异步支持 - http://msdn.microsoft.com /en-us/library/system.net.webclient.aspx

HttpClient is still in Preview - http://msdn.microsoft.com/en-us/library/system.net.http.httpclient(v=vs.110).aspx

Either you saw that or someone's handwritten version.

Webclient is the tried and tested as of now.

WebClient has async support too - http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文