C#模擬post請求調用request.GetResponse()超時,報 System.Net.WebException: The operation has timed out.

C#模擬post請求調用request.GetResponse()超時,報 System.Net.WebException: The operation has timed out.

  • 解決方法1:

設置:
request.ServicePoint.Expect100Continue = false;

  • 解決方法2,嘗試使用using
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
    return reader.ReadToEnd();
}
  • 解決方法3:

設置:System.Net.ServicePointManager.DefaultConnectionLimit = 200;

  • 解決方法4:

設置如下兩個屬性

request.Timeout = Timeout.Infinite;
request.KeepAlive = true;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章