How to Check URLs Using .NET
page 1 of 1
Published: 25 Oct 2003
Unedited - Community Contributed
Abstract
A look at how to stop broken links on your site with .NET. Use Screen Scraping methods to check the validity of links on your site, from checking for 404 errors to ensuring that URLs don't point at something completely different than intended.
by Damian Manifold
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 48848/ 59

So you display links to other sites on your site, sooner or later one is bound to end up a dead link, or you may have lots of bookmarks and you cannot be bothered to weed out all the old ones that no longer point where they used to. 

Here is a solution to your problem, an automated link checking routine.

Source Code
Check.aspx The URL entry form and result page
Check.aspx.vb Code behind to check the URL

In the above code you will see that it uses 4 ways to identify problem URLs. 

  • Check the URL for errors, e.g.: invalid address or 404 page not found.
  • Check the URL is not redirected either server side or client side, indicating the site has moved
These next 2 require some prior knowledge of the site
  • Check the title has not change, indicating the site is not what it used to be
  • Check the page has not changed, this only works for static pages

Examples
Check.aspx the Check URL in action

Articles
Importing bookmark.htm with Regular Expressions by Damian Manifold



User Comments

Title: a   
Name: b
Date: 5/8/2012 6:18:13 AM
Comment:
123
Title: code   
Name: mustufa
Date: 1/19/2011 10:17:09 AM
Comment:
How to Check URLs Using .NET
i want to download assembly of this code
Title: Check URL   
Name: Goldie
Date: 11/19/2007 9:55:38 PM
Comment:
this item is brillant!
With a few minor changes to the code behind it works brillantly !! well done

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2014 ASPAlliance.com  |  Page Processed at 12/22/2014 8:31:37 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search