Search notes:

System.Net.WebClient (class)

System.Net.WebClient inherits from System.ComponentModel.Component and is used to send and receive data to and from a URI.
Microsofts recommends to use System.Net.Http.HttpClient rather than S.N.WebClient.

Methods and properties

AllowReadStreamBuffering
AllowWriteStreamBuffering
BaseAddress
CachePolicy
CancelAsync()
Credentials
DownloadData()
DownloadDataAsync()
DownloadDataTaskAsync()
DownloadFile()
DownloadFileAsync()
DownloadFileTaskAsync()
DownloadString()
DownloadStringAsync()
DownloadStringTaskAsync()
Encoding
GetWebRequest()
GetWebResponse()
Headers
IsBusy
OnDownloadDataCompleted()
OnDownloadFileCompleted()
OnDownloadProgressChanged()
OnDownloadStringCompleted()
OnOpenReadCompleted()
OnOpenWriteCompleted()
OnUploadDataCompleted()
OnUploadFileCompleted()
OnUploadProgressChanged()
OnUploadStringCompleted()
OnUploadValuesCompleted()
OnWriteStreamClosed()
OpenRead()
OpenReadAsync()
OpenReadTaskAsync()
OpenWrite()
OpenWriteAsync()
OpenWriteTaskAsync()
Proxy
QueryString
ResponseHeaders
UploadData()
UploadDataAsync()
UploadDataTaskAsync()
UploadFile()
UploadFileAsync()
UploadFileTaskAsync()
UploadString()
UploadStringAsync()
UploadStringTaskAsync()
UploadValues()
UploadValuesAsync()
UploadValuesTaskAsync()
UseDefaultCredentials

Simple C-Sharp example

The following simple C# example tries to demonstrate how System.Net.WebClient might be used.
using System;
using System.Net;

class M {

   public static void Main(String[] argv) {

      if (argv.Length != 1) {
         Console.WriteLine("Provide URL to fetch data from");
         return;
      }

      var client = new WebClient();
      client.Headers.Add("User-Agent", ".NET-WebClient/1.0 TQ84");

      var content = client.DownloadString(argv[0]);
      Console.WriteLine(content); 
   }
}
Github repository .NET-API, path: /System/Net/WebClient.cs
After compiling, the executbable can be started with an URL:
C:\> WebClient.exe https://google.com

See also

The UploadFile() method can be used to upload a file with a HTTP POST request or an FTP STOR command.
Sometimes, the property SecurityProtocol of System.Net.ServicePointManager needs to be set to Tls12.

Index