Web客户端与HttpWebRequest的/ HttpWebResponse [英] WebClient vs. HttpWebRequest/HttpWebResponse
问题描述
在我看来,大部分可以取得什么成就是 的HttpWebRequest /响应
也可以实现与 Web客户端
类。我读的地方, Web客户端
是一个高层次的包装的WebRequest /响应
。
到目前为止,我看不到可以完成与的HttpWebRequest /响应
无法完成与 Web客户端
什么,也没有在那里的HttpWebRequest /响应会给你更多的细粒度控制。
It seems to me that most of what can be accomplished with HttpWebRequest/Response
can also be accomplished with the WebClient
class. I read somewhere that WebClient
is a high-level wrapper for WebRequest/Response
.
So far, I can't see anything that can be accomplished with HttpWebRequest/Response
that can not be accomplished with WebClient
, nor where HttpWebRequest/Response will give you more "fine-grained" control.
当我应该使用Web客户端,当的HttpWebRequest /响应
? (显然,的HttpWebRequest /响应
是HTTP特有的。)
When should I use WebClient and when HttpWebRequest/Response
? (Obviously, HttpWebRequest/Response
are HTTP specific.)
如果的HttpWebRequest /响应
较低的水平,那么 Web客户端
,我有什么可以完成与 HttpWebRequest的请求/响应
,我不能用 Web客户端完成
?
If HttpWebRequest/Response
are lower level then WebClient
, what can I accomplish with HttpWebRequest/Response
that I cannot accomplish with WebClient
?
推荐答案
使用的HttpWebRequest
给你的要求更多的控制。您可以设置cookie,头,协议等..在响应中,您还可以检索cookie和头
Using HttpWebRequest
gives you more control on the request. You can set cookies, headers, protocol, etc... In the response, you can also retrieve the cookies and headers
这篇关于Web客户端与HttpWebRequest的/ HttpWebResponse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!