C# WebClient UploadString(Uri, String, String)

Description

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

Syntax

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


public string UploadString(
  Uri address,//from  www . ja  va2 s .c o  m
  string method,
  string data
)

Parameters

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

  • address - The URI of the resource to receive the string. This URI must identify a resource that can accept a request sent with the method method.
  • method - The HTTP method used to send the string to the resource. If null, the default is POST for http and STOR for ftp.
  • data - The string to be uploaded.

Returns

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

Example


using System;/*  w w w  .ja  va2s.co m*/
using System.Net;
using System.Net.Sockets;

public class Example
{
   public static void Main()
   {
        string data = "data";
        string method = "POST";
        WebClient client = new WebClient ();
        string reply = client.UploadString (new Uri("http://your server"), method, data);

        Console.WriteLine (reply);
    
   }
}




















Home »
  C# Tutorial »
    System.Net »




Cookie
Dns
IPAddress
IPEndPoint
IPHostEntry
WebClient