瞭解這一點,但沒有看到如何實際延長時間限制的迴應: https://devcenter.heroku.com/articles/request-timeout如何延長的時間長度HTTP響應
string responseContents = string.Empty;
//get web request to wait 5 mins
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
byte[] requestBytes = System.Text.Encoding.ASCII.GetBytes(message);
request.Method = "POST";
request.ContentType = "text/xml;charset=utf-8";
request.ContentLength = requestBytes.Length;
using (Stream requestStream = request.GetRequestStream())
{
requestStream.Write(requestBytes, 0, requestBytes.Length);
requestStream.Close();
}
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
using (StreamReader sr = new StreamReader(response.GetResponseStream(), System.Text.Encoding.Default))
{
responseContents = sr.ReadToEnd();
}
}
問題是,很多東西在服務器回事,需要時間來返回響應,具體取決於文件大小。
這是說不能轉換雙它? – John
我修復了答案。你需要將總數毫秒從double轉換爲int。('(int)')。 – BatteryBackupUnit