开发者

.NET WebClient.UploadValues vs WebClient.UploadData

I am writing a class library to perform operations on a site outside my control. The site is accepting form-posts as input.

Can anyone tell me if there is a difference between these two methods except the form of the data to upload?

    System.Net.WebClient.UploadData(Uri, Byte[]);

    System.Net.WebClient.UploadValues(String, NameValueCollection);

I have no objections to 开发者_C百科arrange data either way, but started to wonder what the difference actually is, and it is still nagging me in some strange way, not knowing if there is a difference.


Both "POST" the data to the server. If you use UploadValues, the values will be made available to the server in the Request.Form collection which is how a normal HTML form works. UploadData gives you more flexibility since no escaping is performed on your data. Its up to you to format the data in a way that the server will understand. As a consequence of this, you can use UploadData to duplicate the behavior of UploadValues.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜