C# WebClient UploadValues(Uri, NameValueCollection)

Description

WebClient UploadValues(Uri, NameValueCollection) Uploads the specified name/value collection to the resource identified by the specified URI.

Syntax

WebClient.UploadValues(Uri, NameValueCollection) has the following syntax.


public byte[] UploadValues(
  Uri address,
  NameValueCollection data
)

Parameters

WebClient.UploadValues(Uri, NameValueCollection) has the following parameters.

  • address - The URI of the resource to receive the collection.
  • data - The NameValueCollection to send to the resource.

Returns

WebClient.UploadValues(Uri, NameValueCollection) method returns

Example


using System;/* w w w.j  ava2  s.c  o m*/
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(new Uri(uriString), myNameValueCollection);
        Console.WriteLine("\nResponse received was :\n{0}", Encoding.ASCII.GetString(responseArray));


    }
}




















Home »
  C# Tutorial »
    System.Net »




Cookie
Dns
IPAddress
IPEndPoint
IPHostEntry
WebClient