HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Timeout = 20000;
using (WebResponse response = request.GetResponse())
using (var stream = response.GetResponseStream())
using (var reader = new StreamReader(stream))
{
var result = reader.ReadToEnd();
// Do something with result
}
在上面的例子中,我定義了一個超時,如果碰巧發生了超時,我怎麼會知道結果是空的?Web請求超時處理?
我收到任何響應類型嗎?
我如何確保我超時?
感謝那正是我所尋找的我並不完全確定。 – Prix 2011-03-08 12:13:09