开发者

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 a开发者_高级运维nd 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜