C# WebClient UploadValues(String, String, NameValueCollection)
Description
WebClient UploadValues(String, String, NameValueCollection)
Uploads the specified name/value collection to the resource identified
by the specified URI, using the specified method.
Syntax
WebClient.UploadValues(String, String, NameValueCollection)
has the following syntax.
public byte[] UploadValues(
string address,//from w w w . j a v a 2 s .com
string method,
NameValueCollection data
)
Parameters
WebClient.UploadValues(String, String, NameValueCollection)
has the following parameters.
address
- The URI of the resource to receive the collection.method
- The HTTP method used to send the file to the resource. If null, the default is POST for http and STOR for ftp.data
- The NameValueCollection to send to the resource.
Returns
WebClient.UploadValues(String, String, NameValueCollection)
method returns
Example
//ww w. j a va 2 s .c o m
using System;
using System.Net;
using System.Net.Sockets;
using System.Collections.Specialized;
using System.Text;
public class Example
{
public static void Main()
{
string uriString = "http://your server";
WebClient myWebClient = new WebClient();
NameValueCollection myNameValueCollection = new NameValueCollection();
string name = "HTML";
string age = "23";
string address = "W3C";
myNameValueCollection.Add("Name", name);
myNameValueCollection.Add("Address", address);
myNameValueCollection.Add("Age", age);
byte[] responseArray = myWebClient.UploadValues(uriString, "POST", myNameValueCollection);
Console.WriteLine("\nResponse received was :\n{0}", Encoding.ASCII.GetString(responseArray));
}
}