我有一個問題,在下載數據時顯示錯誤「The Operation has timed out」。如何解決「操作超時」錯誤
我能做些什麼來解決這個錯誤?我使用Win窗體(C#)這裏是我的代碼,請檢查並提供建議。我應該在哪裏更改代碼,請幫我...
public void ProcessData()
{
try
{
string MessageTitle = "";
int pages = Convert.ToInt32(txtPages.Text);
for (int k = Count; k <= pages; k++)
{
string url = "http://www.yellowpages.com/" +StateName.ToLower()+ "/" + CategoryName + "?g=" + StateName + "&page=" + k + "&q=" + CategoryName + "";//txtYP.Text + k;
System.Net.HttpWebRequest httpRequest;
System.Net.HttpWebResponse httpResponse;
System.IO.StreamReader SReader;
string html;
httpRequest = (System.Net.HttpWebRequest)(System.Net.HttpWebRequest.Create(url));
httpRequest.Method = "GET";
httpResponse = (System.Net.HttpWebResponse)(httpRequest.GetResponse());
SReader = new StreamReader(httpResponse.GetResponseStream());
html = SReader.ReadToEnd();
string strDummy = html;
httpResponse.Close();
感謝您給予回覆,,,是的,我能夠瀏覽從網絡瀏覽器的網址...如何設置Httprequest時間,請helpme ....在哪裏我可以編寫代碼... – 2011-05-04 08:00:10
爲什麼它顯示此錯誤「請求被中止:連接意外關閉。」 – 2011-05-04 08:08:55
在我看來,你正在錘擊一個你不擁有請求的站點,並且正在被他們的防火牆\ bot機制阻止。 – Arunas 2011-05-04 10:01:43