473,804 Members | 3,273 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Difference between WebClient and HttpWebRequest/Response??

What is the difference (pros and cons) between retrieving data from the web
using System.Web.WebC lient and using HttpWebRequest and Response to get the
data? The WebClient download methods seem to neatly encapsulate the multiple
steps (request.Create ; request.GetResp onse; response.GetRes ponseStream ...)
required with the traditional HttpWebRequest/Response approach. I am trying
to crawl urls and download data.
Nov 17 '05 #1
1 11941
In short, HttpWebRequest gives you more fine grained control over your
request. WebClient does not. It encapsulates most of the stuff for you.

WebClient is very useful if you want to do specialized, one-off tasks, eg:
download file, do forms post etc.

HttpWebRequest is useful if you want to do more complicated stuff.

--
feroze

-----------------
This posting is provided as-is. It offers no warranties and assigns no
rights.

See http://weblogs.asp.net/feroze_daud for System.Net related posts.
----------------

"Jason Manfield" <Ja***********@ discussions.mic rosoft.com> wrote in message
news:E7******** *************** ***********@mic rosoft.com...
What is the difference (pros and cons) between retrieving data from the
web
using System.Web.WebC lient and using HttpWebRequest and Response to get
the
data? The WebClient download methods seem to neatly encapsulate the
multiple
steps (request.Create ; request.GetResp onse; response.GetRes ponseStream
...)
required with the traditional HttpWebRequest/Response approach. I am
trying
to crawl urls and download data.

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1536
by: Nick Jacobsen | last post by:
Hoping that someone else has either run into this, or can point me in the right direction to fix it. I am making an PROPFIND HTTP Request to a WebDav Mail server (hotmail,. to be specific) using HTTPWebRequest, and everthing goes fine, until the server responds with a "207 MULTISTATUS" response type - at this point, the program just hangs *forever*. I traced this down using proxyTrace and watching the HTTP requests go back and forth - so...
1
2802
by: Rajesh S | last post by:
Hi, Is it possible to upload multiple files using WebClient Class(Like HttpRequest Class).? If Possible please help!!
9
15092
by: Glen | last post by:
I'm writing a console utility to download specific files from web sites based on the command line options. In most cases, I can trap the 404 error when the file isn't available because the operator mistyped the URL or it's offline for whatever reason. The problem I'm running into is with certain sites where the admin has set up a redirect to handle the 404 condition and redirects the request to another page. In this case, the...
4
1537
by: Ron Vecchi | last post by:
I know this has messiness written all over it but I have a question about using HttpWebRequest/Response to essentially spider a website and post information to the forms. The (very) basic goal is to progmattically access a login account by posting the username and password and then maintaining the session so that the program can continue to access web pages that require a valid login sesssion. The big if for me is maintaining the...
14
2976
by: tomer | last post by:
Clear DayHello, I have implemented a download manger in .NET that overrides Internet Explorer's bult-in download manager. I using HttpWebRequest/Response to download the files. All is working well except when I try to download an attachment file from a web-based mailbox. I've tried using credentials and saving the cookies, nothing helps.
3
1857
by: Lars Netzel | last post by:
I want to press a Linkbutton (in a DatagridItem) and return a file that is not shared in the IIS. I want to disallow "deeplinking". The following code works fine (it sends the file I want) but I want it to be parallel to the webpage, not replacing the page with the datagrid.. how do I force the file download to a new window? Public Sub SendFile(ByVal Filepath As String) Response.Clear()
1
1455
by: kellox | last post by:
I'm implementing a propiertary protocol for a company which is actually an extension of HTTP (extended with some specific headers). If I use the .NET class HttpWebRequest and HttpWebResponse respectively I can easily communicate with the server by setting the necessary headers. Since any further requests/responses should be sent over the connection, established after the first request, for receiving events from the server, I have to left the...
7
7789
by: raids51 | last post by:
Hello, i have a program that downloads a file using the httpwebrequest/response, and it usually works, but sometimes it will freeze at a random part of the download without an error. here is the code: 'Creating the request and getting the response Dim theResponse As HttpWebResponse Dim theRequest As HttpWebRequest Try 'Checks if the file exist theRequest = WebRequest.Create(Me.Filelocation) ...
0
10583
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9160
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.