简体   繁体   中英

Using WebClient c#

I have seen some links that tells how to use web client but one thing is still un clear to me as i am not sharp developer.

  1. Dose this implements POST
  2. Difference between HttpWebRequest
  3. How to determine Fields from page source in which values are to be placed
  4. How values should be placed

I studied http://www.daveamenta.com/tag/webclient/

It would be great if some one gives an example of html feilds and how to use them in web client

Does this implements POST

Yes, you can use the UploadString , UploadData , and UploadValues methods

Difference between HttpWebRequest

Basically, WebClient is just a wrapper for WebRequest ( FtpWebRequest , HttpWebRequest ...), to make it easier to use. It doesn't give you as much control, but it's enough for simple scenarios

How to determine Fields from page source in which values are to be placed

I don't really understand what you mean...

How values should be placed

Are you talking about form fields? You can use the UploadValues method, which does the same as submitting an HTML form with POST

MSDN is the best place to get exact answers for .Net stuff.

Here's an article on WebClient versus HttpWebRequest. Basically WebClient is designed to be quick and easy. HttpWebRequest is more complex, but more powerful.

http://blogs.msdn.com/b/silverlight_sdk/archive/2008/04/01/using-webclient-and-httpwebrequest.aspx

There has also been lengthy discussion on this topic on SO before:

WebClient vs. HttpWebRequest/HttpWebResponse

webclient is a simple way to get the content from web-page something like

webclient client= new webclient();
string content = client.downloadstring('google'.com');

for downloading the page using webclient is simple but using httprequest difficult.

simple thing can be done by webclient without write many line of code.

but many hard not yet possible in webclient.

so simply HttpWebRequest is better option then webclient.

see here a little example

http://geekswithblogs.net/anirudha/archive/2010/07/25/parsing-text-in-c-sharp.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM