check if link is active?

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?
 
P

Peter Rilling

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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top