Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 684
Afnan Bashir Avatar asked Dec 01 '25 05:12

Afnan Bashir


2 Answers

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

like image 53
Thomas Levesque Avatar answered Dec 03 '25 19:12

Thomas Levesque


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

like image 42
Doobi Avatar answered Dec 03 '25 18:12

Doobi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!