Kenn
Kenn

Reputation: 2769

Is WebClient preferred over HttpClient when creating rest client in .NET

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!

Upvotes: 2

Views: 6357

Answers (1)

manojlds
manojlds

Reputation: 301037

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

Upvotes: 3

Related Questions