C# WebClient UploadString(String, String)
Description
WebClient UploadString(String, String)
Uploads the
specified string to the specified resource, using the POST method.
Syntax
WebClient.UploadString(String, String)
has the following syntax.
public string UploadString(
string address,
string data
)
Parameters
WebClient.UploadString(String, 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(String, String)
method returns A String containing the response sent by the server.
Example
The following code example demonstrates calling this method.
using System;//w ww. jav a 2s .c om
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 ("http://your server", data);
Console.WriteLine (reply);
}
}