.NET WebClient.UploadValues VS WebClient.UploadData [英] .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 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.
推荐答案
两者POST将数据发送到服务器。如果你使用 UploadValues
,该值将提供给在的Request.Form
收集这是怎样一个服务器普通的HTML表单的工作。 UploadData code>给你,因为没有转义对数据进行更多的灵活性。它由你来的方式,服务器会理解的数据格式。由于这一结果,你可以使用
UploadData code>复制的行为
UploadValues
。
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
.
这篇关于.NET WebClient.UploadValues VS WebClient.UploadData的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!