C# WebClient UploadString(String, String, String)

Description

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

Syntax

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


public string UploadString(
  string address,/*from www .  j a  v  a  2s  .  com*/
  string method,
  string data
)

Parameters

WebClient.UploadString(String, 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(String, String, String) method returns A String containing the response sent by the server.

Example


//www .jav a 2s  . c o  m
using System;
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 ("http://your server", method, data);

        Console.WriteLine (reply);
    
   }
}




















Home »
  C# Tutorial »
    System.Net »




Cookie
Dns
IPAddress
IPEndPoint
IPHostEntry
WebClient