在 .NET 中创建 REST 客户端时,WebClient 是否优于 HttpClient?
我只是一般性地学习 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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