1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Broken Link Report

Broken Link Report

3 posts, 0 answered
  1. Jodie
    Jodie avatar
    59 posts
    Registered:
    09 Oct 2012
    27 Jan 2010
    Link to this post
    Hi all,

    I'm wondering how I might go about generating a Broken Link Report for our entire site. We have say 1000 pages and then we deleted 200 of them and of course their links are still throughout the other pages. I'm sure theres probably an easy solution.

    Any help is appreciated

    Cheers

    Jodie
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    27 Jan 2010
    Link to this post
    Hi Jodie,

    You can use the WebRequest and  WebResponse classes to check the HttpStatus.

    public bool CheckUrl(string url) 
        try 
        
            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url); 
               
            using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse()) 
            
                if (webResponse.StatusCode == HttpStatusCode.OK) 
                
                    return true
                
            
        
        catch (WebException) 
        
             
        
       
        return false
    }

    You can also get the status code from the response and use switch loop
     int statusCode = (int)webResponse.StatusCode;

    Another option is using third party software that will perform this check automatically and return possible broken links.

    Generally if you want to search in the content you have to loop through all pages, all controls find all urls in the content and check them.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Jodie
    Jodie avatar
    59 posts
    Registered:
    09 Oct 2012
    27 Jan 2010
    Link to this post
    Hi Ivan,

    Thanks for the quick response. I'll follow this direction and see what I come up with.

    Cheers

    Jodie
Register for webinar
3 posts, 0 answered