C# WebClient UploadString(Uri, String)

Description

WebClient UploadString(Uri, String) Uploads the specified string to the specified resource, using the POST method.

Syntax

WebClient.UploadString(Uri, String) has the following syntax.


public string UploadString(
  Uri address,
  string data
)

Parameters

WebClient.UploadString(Uri, String) has the following parameters.

  • address - The URI of the resource to receive the string. For Http resources, this URI must identify a resource that can accept a request sent with the POST method, such as a script or ASP page.
  • data - The string to be uploaded.

Returns

WebClient.UploadString(Uri, String) method returns A String containing the response sent by the server.

Example


using System;//w w w  .j  av a2s  .c o  m
using System.Net;
using System.Net.Sockets;

public class Example
{
   public static void Main()
   {
        string data = "data";
        WebClient client = new WebClient ();

        client.Encoding = System.Text.Encoding.UTF8;

        string reply = client.UploadString (new Uri("http://your server"), data);

        Console.WriteLine (reply);
    
   }
}




















Home »
  C# Tutorial »
    System.Net »




Cookie
Dns
IPAddress
IPEndPoint
IPHostEntry
WebClient