.NET WebClient.UploadValues ​​vs WebClient.UploadData

I am writing a class library to perform operations on a site beyond my control. The site accepts message forms as input.

Can someone tell me if there is a difference between the two methods other than the data form for upload?

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

I have no objection to streamline the data anyway, but started to wonder what the difference really is, and it still indulges me in some strange way, not knowing if there is a difference.

+6
webclient
source share
1 answer

Both "POST" transfer data to the server. If you use UploadValues , the values ​​will be available for the server in the Request.Form collection, which works with a normal HTML form. UploadData gives you more flexibility since shielding is not performed on your data. It is up to you to format the data so that the server understands. As a result of this, you can use UploadData to duplicate the behavior of UploadValues .

+11
source share

All Articles