WebClient.UploadValuesAsync WebClient.UploadValuesAsync WebClient.UploadValuesAsync WebClient.UploadValuesAsync Method

Definition

Uploads the specified name/value collection to the resource identified by the specified URI. These methods do not block the calling thread.

Overloads

UploadValuesAsync(Uri, NameValueCollection) UploadValuesAsync(Uri, NameValueCollection) UploadValuesAsync(Uri, NameValueCollection) UploadValuesAsync(Uri, NameValueCollection)

Uploads the data in the specified name/value collection to the resource identified by the specified URI. This method does not block the calling thread.

UploadValuesAsync(Uri, String, NameValueCollection) UploadValuesAsync(Uri, String, NameValueCollection) UploadValuesAsync(Uri, String, NameValueCollection) UploadValuesAsync(Uri, String, NameValueCollection)

Uploads the data in the specified name/value collection to the resource identified by the specified URI, using the specified method. This method does not block the calling thread.

UploadValuesAsync(Uri, String, NameValueCollection, Object) UploadValuesAsync(Uri, String, NameValueCollection, Object) UploadValuesAsync(Uri, String, NameValueCollection, Object) UploadValuesAsync(Uri, String, NameValueCollection, Object)

Uploads the data in the specified name/value collection to the resource identified by the specified URI, using the specified method. This method does not block the calling thread, and allows the caller to pass an object to the method that is invoked when the operation completes.

UploadValuesAsync(Uri, NameValueCollection) UploadValuesAsync(Uri, NameValueCollection) UploadValuesAsync(Uri, NameValueCollection) UploadValuesAsync(Uri, NameValueCollection)

Uploads the data in the specified name/value collection to the resource identified by the specified URI. This method does not block the calling thread.

public:
 void UploadValuesAsync(Uri ^ address, System::Collections::Specialized::NameValueCollection ^ data);
public void UploadValuesAsync (Uri address, System.Collections.Specialized.NameValueCollection data);
member this.UploadValuesAsync : Uri * System.Collections.Specialized.NameValueCollection -> unit
Public Sub UploadValuesAsync (address As Uri, data As NameValueCollection)

Parameters

address
Uri Uri Uri Uri

The URI of the resource to receive the collection. This URI must identify a resource that can accept a request sent with the default method.

Exceptions

The address parameter is null.

-or-

The data parameter is null.

The URI formed by combining BaseAddress and address is invalid.

-or-

There was no response from the server hosting the resource.

Remarks

This method sends a string to a resource. The string is sent asynchronously using thread resources that are automatically allocated from the thread pool. Before uploading the string, this method converts it to a Byte array using the encoding specified in the Encoding property. To receive notification when the string upload completes, you can add an event handler to the UploadStringCompleted event.

This method does not block the calling thread while the string is being sent. To send a string and block while waiting for the server's response, use one of the UploadString methods.

Asynchronous operations that have not completed can be canceled using the CancelAsync method.

If the BaseAddress property is not an empty string ("") and address does not contain an absolute URI, address must be a relative URI that is combined with BaseAddress to form the absolute URI of the requested data. If the QueryString property is not an empty string, it is appended to address.

This method uses the STOR command to upload an FTP resource. For an HTTP resource, the POST method is used.

Note

This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing in the .NET Framework.

UploadValuesAsync(Uri, String, NameValueCollection) UploadValuesAsync(Uri, String, NameValueCollection) UploadValuesAsync(Uri, String, NameValueCollection) UploadValuesAsync(Uri, String, NameValueCollection)

Uploads the data in the specified name/value collection to the resource identified by the specified URI, using the specified method. This method does not block the calling thread.

public:
 void UploadValuesAsync(Uri ^ address, System::String ^ method, System::Collections::Specialized::NameValueCollection ^ data);
public void UploadValuesAsync (Uri address, string method, System.Collections.Specialized.NameValueCollection data);
member this.UploadValuesAsync : Uri * string * System.Collections.Specialized.NameValueCollection -> unit
Public Sub UploadValuesAsync (address As Uri, method As String, data As NameValueCollection)

Parameters

address
Uri Uri Uri Uri

The URI of the resource to receive the collection. This URI must identify a resource that can accept a request sent with the method method.

method
String String String String

The method used to send the string to the resource. If null, the default is POST for http and STOR for ftp.

Exceptions

The address parameter is null.

-or-

The data parameter is null.

The URI formed by combining BaseAddress and address is invalid.

-or-

There was no response from the server hosting the resource.

-or-

method cannot be used to send content.

Remarks

This method sends the data contained in a NameValueCollection to the address resource. Use this method to send form data to a URI for processing. The data is sent using the form-urlencoded media type; the Content-Type header value must be set to "application/x-www-form-urlencoded". The header is set correctly by default. The UploadValuesAsync methods throw a WebException if you call this method with a different Content-Type header value set in the Headers collection.

If the method method is not understood by the server, the underlying protocol classes determine what occurs. Typically, a WebException is thrown with the Status property set to indicate the error.

The NameValueCollection is sent asynchronously using thread resources that are automatically allocated from the thread pool. To receive notification when the upload operation completes, add an event handler to the UploadValuesCompleted event.

This method does not block the calling thread while the string is being sent. To send a string and block while waiting for the server's response, use one of the UploadValues methods.

Asynchronous operations that have not completed can be canceled using the CancelAsync method.

If the BaseAddress property is not an empty string ("") and address does not contain an absolute URI, address must be a relative URI that is combined with BaseAddress to form the absolute URI of the requested data. If the QueryString property is not empty, it is appended to address.

Note

This member outputs trace information when you enable network tracing in your application. For more information see Network Tracing in the .NET Framework.

UploadValuesAsync(Uri, String, NameValueCollection, Object) UploadValuesAsync(Uri, String, NameValueCollection, Object) UploadValuesAsync(Uri, String, NameValueCollection, Object) UploadValuesAsync(Uri, String, NameValueCollection, Object)

Uploads the data in the specified name/value collection to the resource identified by the specified URI, using the specified method. This method does not block the calling thread, and allows the caller to pass an object to the method that is invoked when the operation completes.

public:
 void UploadValuesAsync(Uri ^ address, System::String ^ method, System::Collections::Specialized::NameValueCollection ^ data, System::Object ^ userToken);
public void UploadValuesAsync (Uri address, string method, System.Collections.Specialized.NameValueCollection data, object userToken);
member this.UploadValuesAsync : Uri * string * System.Collections.Specialized.NameValueCollection * obj -> unit
Public Sub UploadValuesAsync (address As Uri, method As String, data As NameValueCollection, userToken As Object)

Parameters

address
Uri Uri Uri Uri

The URI of the resource to receive the collection. This URI must identify a resource that can accept a request sent with the method method.

method
String String String String

The HTTP method used to send the string to the resource. If null, the default is POST for http and STOR for ftp.

userToken
Object Object Object Object

A user-defined object that is passed to the method invoked when the asynchronous operation completes.

Exceptions

The address parameter is null.

-or-

The data parameter is null.

The URI formed by combining BaseAddress and address is invalid.

-or-

There was no response from the server hosting the resource.

-or-

method cannot be used to send content.

Remarks

This method sends the data contained in a NameValueCollection to the address resource. Use this method to send form data to a URI for processing. The data is sent using the form-urlencoded media type; the Content-Type header value must be set to "application/x-www-form-urlencoded". The header is set correctly by default. The UploadValuesAsync methods throw a WebException if you call this method with a different Content-Type header value set in the Headers collection.

If the method method is not understood by the server, the underlying protocol classes determine what occurs. Typically, a WebException is thrown with the Status property set to indicate the error.

The NameValueCollection is sent asynchronously using thread resources that are automatically allocated from the thread pool. To receive notification when the upload operation completes, add an event handler to the UploadValuesCompleted event.

This method does not block the calling thread while the string is being sent. To send a string and block while waiting for the server's response, use one of the UploadValues methods.

Asynchronous operations that have not completed can be canceled using the CancelAsync method.

If the BaseAddress property is not an empty string ("") and address does not contain an absolute URI, address must be a relative URI that is combined with BaseAddress to form the absolute URI of the requested data. If the QueryString property is not empty, it is appended to address.

Note

This member outputs trace information when you enable network tracing in your application. For more information see Network Tracing in the .NET Framework.

Applies to