1. Have you tested this with a definite good URL?
2. Have you verified that you are not putting a bad link into your function?
3. Have you verified that the domains are good. Bad domains will 'time out' I believe. Whereas good domains with bad file names will 404.
-Stephen Johnston
At 05:46 AM 1/15/2004, you wrote:
Hi all. I am trying to build an application that checks for broken URLs using the System.Net.WebRequest.Create, but I constantly get this WebException: "The operation has timed-out." Sometimes on 10 out of 50 URLs, sometimes (more often) on 40 out of 50 URLs. I have tried, among other things, setting ServicePointManager.DefaultConnectionLimit to 200, increasing the TimeOut and setting Keep-Alive to false, but nothing seems to solve the problem.
This is the method I am using in an iteration for about 50 links:
protected string TestLink(string link) { try {
ServicePointManager.DefaultConnectionLimit = 200; objRequest = (HttpWebRequest) System.Net.WebRequest.Create(link);
try { objResponse = (HttpWebResponse) objRequest.GetResponse(); } catch(WebException exc) { WebExceptionStatus exceptionStatus = exc.Status; return String.Format("{2}\n WebException, Msg: {0}<br />Status: {1 <br />", exc.Message, exceptionStatus.ToString(), link); } finally { try { objResponse.Close(); } catch (Exception ex) {} } } catch(UriFormatException exc) { return String.Format("{1}\n UriFormatException: {0}", exc.Message, link); } catch(NotSupportedException exc) { return String.Format("{1}\n NotSupportedException: {0}", exc.Message, link); } catch(Exception exc) { return String.Format("{1}\n Exception: {0}", exc.Message, link); }
return String.Format("{0}\n Success: {1} ({2})", link, objResponse.StatusCode, objResponse.StatusDescription); }
Can someone tell me where I am going wrong?
I am calling the method from an exe-file on Windows 2000 Server and Windows XP Professional (same result).
Thanks.
/joakim
=================================== This list is hosted by DevelopMentor� http://www.develop.com Some .NET courses you may be interested in:
NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls
View archives and manage your subscription(s) at http://discuss.develop.com
=================================== This list is hosted by DevelopMentor� http://www.develop.com Some .NET courses you may be interested in:
NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls
View archives and manage your subscription(s) at http://discuss.develop.com
