Web客户端与HttpWebRequest的/ HttpWebResponse [英] WebClient vs. HttpWebRequest/HttpWebResponse

查看:156
本文介绍了Web客户端与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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆