check if link is active?

  • Thread starter Thread starter DaveF
  • Start date Start date
D

DaveF

Is there a way to be able to check a url link to see if it is active or not?
Example. I put urls to images in an Iframe on my site. If they change the
url, It gives me an image not found error. I want to make a service that
runs every 3 days to check theses links for validity?
 
You could write a service or scheduled task that will go out and ping the
site.

Basically you could do something like (this may not work as-is, but it give
you an idea):

try{
HttpWebRequest req =
(HttpWebRequest)WebRequest.Create(http://mysite.com/mypage.aspx);
HttpWebResponse resp = req.GetResponse();
} catch(WebException e) {
// Status code in "e" will tell you why it failed.
}

(http://mysite.com/mypage.aspx);
 
Back
Top