C# 中 WebClient HttpClient 的区别

.Net技术 码拜 9年前 (2016-02-02) 10269次浏览 0个评论

WebClient和HttpClient 的区别对比

Web­Client

Http­Client

可用于 .NET之前的旧版本,如2.0 .NET 4.0 以上. Cre­ated to sup­port the grow­ing need of the Web API REST calls
WinRT appli­ca­tions can­not use WebClient Http­Client can be used with WinRT
Pro­vides progress report­ing for downloads. No progress report­ing for downloads.
Does not reuse resolved DNS, configured-cookies. Can resuse resolved DNS, cookie con­fig­u­ra­tion and other authentication.
You need to new up a Web­Client to make con­cur­rent request. Sin­gle Http­Client can make con­cur­rent requests.
Thin layer over WebRe­quest and WebResponse Thin layer over Http­We­bRe­quest and HttpWebResponse
Mock­ing and test­ing Web­Client is difficult Mock­ing and test­ing Http­Client is easy
支持 FTP. 不支持 FTP.
Both syn­chro­nous and Asyn­chro­nous meth­ods are avail­able for IO bound requests. All IO bound meth­ods in HTTP­Client are asynchronous.

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明C# 中 WebClient HttpClient 的区别
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!