Author: JosephCeasar | Posted on: 10/16/2009 11:56:42 AM | Views : 235

We have in our database a list of URLs.  We need to check that list for invalid/broken links.  That part is easily accomplished by using this function (which I found on the WEB):
bool IsUrlAvailable(string url) { try { HttpWebRequest req = (HttpWebRequest)WebRequest.Create((@"http://"+url).Replace(@"http://http://",@"http://")); using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse()) { if (rsp.StatusCode == HttpStatusCode.OK) return true; } } catch (Exception) { // Eat it because all we want to do is return false } // Otherwise return false; }  

We wrote a procedure that uses the above function ...

Go to the complete details ...