Rebex
Products Downloads Buy Support Contact
Show / Hide Table of Contents

WebClient Class

Namespace: Rebex.Net
Assembly: Rebex.Http.dll (version 8.0.9673)

Provides simple methods to upload and download data from HTTP/HTTPS servers.

Syntax
public class WebClient : IDisposable
Inheritance
Object
WebClient
Implements
IDisposable
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Examples
// initialize new WEB client instance
var client = new Rebex.Net.WebClient();

// attach logger for diagnostic purposes
client.LogWriter = new Rebex.FileLogWriter(@"C:\MyData\web.log");

// do a GET request
var page = client.DownloadString("https://httpbin.org/get");
Console.WriteLine(page);

// do a POST request
page = client.UploadString("https://httpbin.org/post", "Some content.");
Console.WriteLine(page);

// use authentication
client.Credentials = new NetworkCredential("user1", "password2");
page = client.DownloadString("https://httpbin.org/basic-auth/user1/password2");
Console.WriteLine(page);

Constructors

Name Description
WebClient()

Initializes a new instance of the WebClient class.

WebClient(HttpRequestCreator)

Initializes a new instance of the WebClient class with specified HTTP request creator. This enables sharing keep-alive connections between instances of WebClient and WebRequest. However please note that Settings, LogWriter and ValidatingCertificate properties are shared between all instances as well. This means that changing such property affects behavior of all instances as well.

Properties

Name Description
BaseAddress

Gets or sets the base address to simplify multiple requests to one server.

Credentials

Get or sets network credentials to identify a user.

Encoding

Gets or sets the encoding to be used for string upload and download.

Headers

Get or sets a collection of HTTP headers to send with a request.

LogWriter

Gets or sets the LogWriter used by this object.

Proxy

Gets or sets the network proxy to use to access a remote server.

QueryString

Gets or sets the collection of name-value pairs, which will be added into the request's query.

ResponseHeaders

Gets or sets a collection of HTTP headers associated with the response.

Settings

Gets TLS/SSL settings.

Timeout

Gets or sets the length of time in milliseconds before the request times out (specify -1 or 0 to indicate that the request does not time out; minimal value is 1000).

Methods

Name Description
Cancel()

Cancels all currently running requests.

Dispose()

Disposes the WebClient object.

Dispose(Boolean)

Releases the unmanaged resources used by the WebClient and optionally releases the managed resources.

DownloadData(String)

Downloads data from provided URI.

DownloadData(Uri)

Downloads data from provided URI.

DownloadDataAsync(String, Object)

Downloads data from provided URI.

DownloadDataAsync(Uri, Object)

Downloads data from provided URI.

DownloadFile(String, String)

Downloads data from provided URI and save them to the file.

DownloadFile(Uri, String)

Downloads data from provided URI and save them to the file.

DownloadFileAsync(String, String, Object)

Downloads data from provided URI and save them to the file.

DownloadFileAsync(Uri, String, Object)

Downloads data from provided URI and save them to the file.

DownloadString(String)

Downloads a resource from provided URI as a string.

DownloadString(Uri)

Downloads a resource from provided URI as a string.

DownloadStringAsync(String, Object)

Downloads a resource from provided URI as a string.

DownloadStringAsync(Uri, Object)

Downloads a resource from provided URI as a string.

Finalize()

Finalizer. Called by garbage collector during object destruction.

GetHeaders(String)

Downloads headers for provided URI using HEAD request.

GetHeaders(Uri)

Downloads headers for provided URI using HEAD request.

GetHeadersAsync(String, Object)

Downloads headers for provided URI using HEAD request.

GetHeadersAsync(Uri, Object)

Downloads headers for provided URI using HEAD request.

OpenRead(String)

Opens a stream that contains data retrieved from provided URI.

OpenRead(Uri)

Opens a stream that contains data retrieved from provided URI.

OpenReadAsync(String, Object)

Opens a stream that contains data retrieved from provided URI.

OpenReadAsync(Uri, Object)

Opens a stream that contains data retrieved from provided URI.

OpenWrite(String)

Opens a stream that is used to send data to provided URI.

OpenWrite(String, String)

Opens a stream that is used to send data to provided URI.

OpenWrite(Uri)

Opens a stream that is used to send data to provided URI.

OpenWrite(Uri, String)

Opens a stream that is used to send data to provided URI.

OpenWriteAsync(String, Object)

Opens a stream that is used to send data to provided URI.

OpenWriteAsync(String, String, Object)

Opens a stream that is used to send data to provided URI.

OpenWriteAsync(Uri, Object)

Opens a stream that is used to send data to provided URI.

OpenWriteAsync(Uri, String, Object)

Opens a stream that is used to send data to provided URI.

SetSocketFactory(ISocketFactory)

Sets the socket factory to be used to create communication sockets.

UploadData(String, Byte[])

Uploads a data to provided URI and returns a response data of the upload operation.

UploadData(String, String, Byte[])

Uploads a data to provided URI and returns a response data of the upload operation.

UploadData(Uri, Byte[])

Uploads a data to provided URI and returns a response data of the upload operation.

UploadData(Uri, String, Byte[])

Uploads a data to provided URI and returns a response data of the upload operation.

UploadDataAsync(String, Byte[], Object)

Uploads a data to provided URI and returns a response data of the upload operation.

UploadDataAsync(String, String, Byte[], Object)

Uploads a data to provided URI and returns a response data of the upload operation.

UploadDataAsync(Uri, Byte[], Object)

Uploads a data to provided URI and returns a response data of the upload operation.

UploadDataAsync(Uri, String, Byte[], Object)

Uploads a data to provided URI and returns a response data of the upload operation.

UploadFile(String, String)

Uploads a file to provided URI and returns a response data of the upload operation.

UploadFile(String, String, String)

Uploads a data to provided URI and returns a response data of the upload operation.

UploadFile(Uri, String)

Uploads a data to provided URI and returns a response data of the upload operation.

UploadFile(Uri, String, String)

Uploads a data to provided URI and returns a response data of the upload operation.

UploadFileAsync(String, String, Object)

Uploads a file to provided URI and returns a response data of the upload operation.

UploadFileAsync(String, String, String, Object)

Uploads a data to provided URI and returns a response data of the upload operation.

UploadFileAsync(Uri, String, Object)

Uploads a data to provided URI and returns a response data of the upload operation.

UploadFileAsync(Uri, String, String, Object)

Uploads a data to provided URI and returns a response data of the upload operation.

UploadString(String, String)

Uploads a string to provided URI as a new resource.

UploadString(String, String, String)

Uploads a string to provided URI as a new resource.

UploadString(Uri, String)

Uploads a string to provided URI as a new resource.

UploadString(Uri, String, String)

Uploads a string to provided URI as a new resource.

UploadStringAsync(String, String, Object)

Uploads a string to provided URI as a new resource.

UploadStringAsync(String, String, String, Object)

Uploads a string to provided URI as a new resource.

UploadStringAsync(Uri, String, Object)

Uploads a string to provided URI as a new resource.

UploadStringAsync(Uri, String, String, Object)

Uploads a string to provided URI as a new resource.

UploadValues(String, NameValueCollection)

Uploads a name/value collection to a specified URI.

UploadValues(String, String, NameValueCollection)

Uploads a name/value collection to a specified URI.

UploadValues(Uri, NameValueCollection)

Uploads a name/value collection to a specified URI.

UploadValues(Uri, String, NameValueCollection)

Uploads a name/value collection to a specified URI.

UploadValuesAsync(String, NameValueCollection, Object)

Uploads a name/value collection to a specified URI.

UploadValuesAsync(String, String, NameValueCollection, Object)

Uploads a name/value collection to a specified URI.

UploadValuesAsync(Uri, NameValueCollection, Object)

Uploads a name/value collection to a specified URI.

UploadValuesAsync(Uri, String, NameValueCollection, Object)

Uploads a name/value collection to a specified URI.

Events

Name Description
DownloadProgressChanged

Occurs when download progress has changed.

UploadProgressChanged

Occurs when upload progress has changed.

ValidatingCertificate

Occurs when a server certificate needs to be validated.

In This Article
© REBEX ČR s.r.o. Back to top
Privacy policy
Manage cookies