Share via


Sys.Net.WebRequest timeout Property

Gets or sets the time-out value for the Sys.Net.WebRequest instance.

Note

To get or set property values for client API properties, you must call property accessor methods that are named with the get_ and set_ prefixes. For example, to get or set a value for a property such as cancel, you call the get_cancel or set_cancel methods.

var timeout = MyWebRequest.get_timeout();
MyWebRequest.set_timeout(value);

Parameters

Term

Definition

value

The time interval in milliseconds.

Return Value

The current Web request time-out value in milliseconds.

Exceptions

Exception type

Condition

Sys.ArgumentOutOfRangeException

value must be a non-negative integer.

Remarks

The timeout property represents the time interval that the network executor associated with the WebRequest instance waits before timing out the network request.

By setting a time-out interval, you can make sure that a pending network call returns control reliably, instead of waiting for the underlying network stack to time out the request. The network executor interprets a value of zero to mean that it is the responsibility of the underlying network stack to time out.

Example

The following example shows how to set and get the request time-out value. This code is part of a complete example found in the WebRequest class overview.

See Also

Reference

Sys.Net.WebRequestManager Class

Sys.Net.WebRequestExecutor Class

Sys.Net.XMLHttpExecutor Class