HttpWebRequest.ReadWriteTimeout 屬性


取得或設定寫入或讀取資料流時的逾時 (以毫秒為單位)。Gets or sets a time-out in milliseconds when writing to or reading from a stream.

 property int ReadWriteTimeout { int get(); void set(int value); };
public int ReadWriteTimeout { get; set; }
member this.ReadWriteTimeout : int with get, set
Public Property ReadWriteTimeout As Integer



寫入或讀取超時前的毫秒數。預設值為300000毫秒 (5 分鐘) 。The number of milliseconds before the writing or reading times out. The default value is 300,000 milliseconds (5 minutes).


已傳送此要求。The request has already been sent.

為設定作業指定的值小於或等於零,且不等於 InfiniteThe value specified for a set operation is less than or equal to zero and is not equal to Infinite


下列程式碼範例會示範如何設定 ReadWriteTimeout 屬性。The following code example shows how to set the ReadWriteTimeout property.

HttpWebRequest myReq =

myReq.ReadWriteTimeout = 100000;


ReadWriteTimeout當寫入方法所傳回的資料流程, GetRequestStream 或從方法傳回的資料流程讀取時,會使用屬性 GetResponseStreamThe ReadWriteTimeout property is used when writing to the stream returned by the GetRequestStream method or reading from the stream returned by the GetResponseStream method.

具體而言, ReadWriteTimeout 屬性會控制方法的超時時間 Read ,這是用來讀取方法所傳回的資料流程 GetResponseStream ,而 Write 方法則是用來寫入方法所傳回的資料流程 GetRequestStreamSpecifically, the ReadWriteTimeout property controls the time-out for the Read method, which is used to read the stream returned by the GetResponseStream method, and for the Write method, which is used to write to the stream returned by the GetRequestStream method.

若要指定等候要求完成的時間長度,請使用 Timeout 屬性。To specify the amount of time to wait for the request to complete, use the Timeout property.