Breyta

Deila með


WebClient.UploadStringTaskAsync Method

Definition

Uploads the specified string to the specified resource as an asynchronous operation using a task object. These methods do not block the calling thread.

Overloads

UploadStringTaskAsync(Uri, String, String)

Uploads the specified string to the specified resource as an asynchronous operation using a task object.

UploadStringTaskAsync(String, String, String)

Uploads the specified string to the specified resource as an asynchronous operation using a task object.

UploadStringTaskAsync(String, String)

Uploads the specified string to the specified resource as an asynchronous operation using a task object.

UploadStringTaskAsync(Uri, String)

Uploads the specified string to the specified resource as an asynchronous operation using a task object.

UploadStringTaskAsync(Uri, String, String)

Source:
WebClient.cs
Source:
WebClient.cs
Source:
WebClient.cs

Uploads the specified string to the specified resource as an asynchronous operation using a task object.

public:
 System::Threading::Tasks::Task<System::String ^> ^ UploadStringTaskAsync(Uri ^ address, System::String ^ method, System::String ^ data);
public System.Threading.Tasks.Task<string> UploadStringTaskAsync (Uri address, string? method, string data);
public System.Threading.Tasks.Task<string> UploadStringTaskAsync (Uri address, string method, string data);
[System.Runtime.InteropServices.ComVisible(false)]
public System.Threading.Tasks.Task<string> UploadStringTaskAsync (Uri address, string method, string data);
member this.UploadStringTaskAsync : Uri * string * string -> System.Threading.Tasks.Task<string>
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.UploadStringTaskAsync : Uri * string * string -> System.Threading.Tasks.Task<string>
Public Function UploadStringTaskAsync (address As Uri, method As String, data As String) As Task(Of String)

Parameters

address
Uri

The URI of the resource to receive the string. For HTTP resources, this URI must identify a resource that can accept a request sent with the POST method, such as a script or ASP page.

method
String

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

data
String

The string to be uploaded.

Returns

The task object representing the asynchronous operation. The Result property on the task object returns a String containing the response sent by the server.

Attributes

Exceptions

The address parameter is null.

-or-

The data parameter is null.

The URI formed by combining BaseAddress and address is invalid.

-or-

method cannot be used to send content.

-or-

There was no response from the server hosting the resource.

Remarks

Caution

WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete, and you shouldn't use them for new development. Use HttpClient instead.

This operation will not block. The returned Task<TResult> object will complete after the string has been uploaded to the resource. The string is sent asynchronously using thread resources that are automatically allocated from the thread pool.

In .NET Framework and .NET Core 1.0, you can cancel asynchronous operations that have not completed by calling the CancelAsync method.

Before uploading the string, this method converts it to a Byte array using the encoding specified in the Encoding property. This method blocks while the string is transmitted.

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.

Note

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

Applies to

UploadStringTaskAsync(String, String, String)

Source:
WebClient.cs
Source:
WebClient.cs
Source:
WebClient.cs

Uploads the specified string to the specified resource as an asynchronous operation using a task object.

public:
 System::Threading::Tasks::Task<System::String ^> ^ UploadStringTaskAsync(System::String ^ address, System::String ^ method, System::String ^ data);
public System.Threading.Tasks.Task<string> UploadStringTaskAsync (string address, string? method, string data);
public System.Threading.Tasks.Task<string> UploadStringTaskAsync (string address, string method, string data);
[System.Runtime.InteropServices.ComVisible(false)]
public System.Threading.Tasks.Task<string> UploadStringTaskAsync (string address, string method, string data);
member this.UploadStringTaskAsync : string * string * string -> System.Threading.Tasks.Task<string>
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.UploadStringTaskAsync : string * string * string -> System.Threading.Tasks.Task<string>
Public Function UploadStringTaskAsync (address As String, method As String, data As String) As Task(Of String)

Parameters

address
String

The URI of the resource to receive the string. For HTTP resources, this URI must identify a resource that can accept a request sent with the POST method, such as a script or ASP page.

method
String

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

data
String

The string to be uploaded.

Returns

The task object representing the asynchronous operation. The Result property on the task object returns a String containing the response sent by the server.

Attributes

Exceptions

The address parameter is null.

-or-

The data parameter is null.

The URI formed by combining BaseAddress and address is invalid.

-or-

method cannot be used to send content.

-or-

There was no response from the server hosting the resource.

Remarks

Caution

WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete, and you shouldn't use them for new development. Use HttpClient instead.

This operation will not block. The returned Task<TResult> object will complete after the string has been uploaded to the resource. The string is sent asynchronously using thread resources that are automatically allocated from the thread pool.

In .NET Framework and .NET Core 1.0, you can cancel asynchronous operations that have not completed by calling the CancelAsync method.

Before uploading the string, this method converts it to a Byte array using the encoding specified in the Encoding property. This method blocks while the string is transmitted.

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.

Note

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

Applies to

UploadStringTaskAsync(String, String)

Source:
WebClient.cs
Source:
WebClient.cs
Source:
WebClient.cs

Uploads the specified string to the specified resource as an asynchronous operation using a task object.

public:
 System::Threading::Tasks::Task<System::String ^> ^ UploadStringTaskAsync(System::String ^ address, System::String ^ data);
public System.Threading.Tasks.Task<string> UploadStringTaskAsync (string address, string data);
[System.Runtime.InteropServices.ComVisible(false)]
public System.Threading.Tasks.Task<string> UploadStringTaskAsync (string address, string data);
member this.UploadStringTaskAsync : string * string -> System.Threading.Tasks.Task<string>
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.UploadStringTaskAsync : string * string -> System.Threading.Tasks.Task<string>
Public Function UploadStringTaskAsync (address As String, data As String) As Task(Of String)

Parameters

address
String

The URI of the resource to receive the string. For HTTP resources, this URI must identify a resource that can accept a request sent with the POST method, such as a script or ASP page.

data
String

The string to be uploaded.

Returns

The task object representing the asynchronous operation. The Result property on the task object returns a String containing the response sent by the server.

Attributes

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

Caution

WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete, and you shouldn't use them for new development. Use HttpClient instead.

This operation will not block. The returned Task<TResult> object will complete after the string has been uploaded to the resource. The string is sent asynchronously using thread resources that are automatically allocated from the thread pool.

In .NET Framework and .NET Core 1.0, you can cancel asynchronous operations that have not completed by calling the CancelAsync method.

Before uploading the string, this method converts it to a Byte array using the encoding specified in the Encoding property. This method blocks while the string is transmitted.

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.

Note

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

Applies to

UploadStringTaskAsync(Uri, String)

Source:
WebClient.cs
Source:
WebClient.cs
Source:
WebClient.cs

Uploads the specified string to the specified resource as an asynchronous operation using a task object.

public:
 System::Threading::Tasks::Task<System::String ^> ^ UploadStringTaskAsync(Uri ^ address, System::String ^ data);
public System.Threading.Tasks.Task<string> UploadStringTaskAsync (Uri address, string data);
[System.Runtime.InteropServices.ComVisible(false)]
public System.Threading.Tasks.Task<string> UploadStringTaskAsync (Uri address, string data);
member this.UploadStringTaskAsync : Uri * string -> System.Threading.Tasks.Task<string>
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.UploadStringTaskAsync : Uri * string -> System.Threading.Tasks.Task<string>
Public Function UploadStringTaskAsync (address As Uri, data As String) As Task(Of String)

Parameters

address
Uri

The URI of the resource to receive the string. For HTTP resources, this URI must identify a resource that can accept a request sent with the POST method, such as a script or ASP page.

data
String

The string to be uploaded.

Returns

The task object representing the asynchronous operation. The Result property on the task object returns a String containing the response sent by the server.

Attributes

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

Caution

WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete, and you shouldn't use them for new development. Use HttpClient instead.

This operation will not block. The returned Task<TResult> object will complete after the string has been uploaded to the resource. The string is sent asynchronously using thread resources that are automatically allocated from the thread pool.

In .NET Framework and .NET Core 1.0, you can cancel asynchronous operations that have not completed by calling the CancelAsync method.

Before uploading the string, this method converts it to a Byte array using the encoding specified in the Encoding property. This method blocks while the string is transmitted.

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.

Note

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

Applies to