Share via


Timeout Property

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Gets or sets the time-out value in milliseconds for the GetResponse and GetRequestStream methods.

Namespace:  System.Net
Assembly:  System.Http (in System.Http.dll)

Syntax

'Declaration
Public Overrides Property Timeout As Integer
public override int Timeout { get; set; }
public:
virtual property int Timeout {
    int get () override;
    void set (int value) override;
}
abstract Timeout : int with get, set
override Timeout : int with get, set
override function get Timeout () : int
override function set Timeout (value : int)

Property Value

Type: System. . :: . .Int32
The number of milliseconds to wait before the request times out. The default value is 100,000 milliseconds (100 seconds).

Remarks

Timeout is the number of milliseconds that a subsequent synchronous request made with the GetResponse method waits for a response, and the GetRequestStream method waits for a stream. The Timeout applies to the entire request and response, not individually to the GetRequestStream and GetResponse method calls. If the resource is not returned within the time-out period, the request throws a WebException with the Status property set to WebExceptionStatus..::..Timeout.

The Timeout property must be set before the GetRequestStream or GetResponse method is called. Changing the Timeout property after calling the GetRequestStream or GetResponse method has no effect

The Timeout property has no effect on asynchronous requests made with the BeginGetResponse or BeginGetRequestStream method.

To specify the amount of time to wait before a read or write operation times out, use the ReadWriteTimeout property.

A Domain Name System (DNS) query may take up to 15 seconds to return or time out. If your request contains a host name that requires resolution and you set Timeout to a value less than 15 seconds, it may take 15 seconds or more before a WebException is thrown to indicate a timeout on your request.

.NET Framework Security

See Also

Reference

HttpWebRequest Class

System.Net Namespace