Programming SEO – Ping

tortoise

Now that we have an RSS feed we can use the feed to ping the various RSS directories that are available on the Internet.  This will create links back to your site including links back to your inner pages, which are the best links you can get.

You also get the advantage of people searching for information on those sites, finding a link to your site, and eventually coming to your site.

Once again, there is code that has already been written about pinging from ASP.NET.  So I’m not going to bother republishing that content.  Here are some links you might be interested in looking at for the code:

Once you have your basic ping code set up, you’ll need to have your code fire it off.  As mentioned in one of the articles above, you’ll want to make sure you do this in a multi-threaded way.  But you’ll also want to make sure that you don’t ping too often, or you can get your site banned by some of the directories you are trying to notify.

In the code that I implemented, the articles have a time stamp for when they will be published.  So all I need to do in my code is see if there is an article that has been published since the last time I sent out the ping and send out a new ping if there is.

The site I implemented this on is on a web farm, which made the code a little more complicated than yours might need to be, but here’s what I wrote.

 

try
{
    if (Cache["rssDate"] == null)
        Cache["rssDate"] = 
            Controller.GetRSS()[0].Launch_Date;
    if (Cache["lastRssDate"] == null)
        Cache.Add("lastRssDate", 
            Controller.GetLastRssDate(), 
            null, 
            System.Web.Caching.Cache.NoAbsoluteExpiration, 
            new TimeSpan(12, 0, 0), 
            System.Web.Caching.CacheItemPriority.Normal, 
            null);

    DateTime lastRssDate = (DateTime)(Cache["lastRssDate"]);

    DateTime mostRecentRssDate = 
        (DateTime)(Cache["rssDate"]);
    if (Request.Url.Host.ToLower()
        .Contains("www.domain.com") && 
        mostRecentRssDate > lastRssDate)
    {
        // double check because we are on a 
        // farm and don't want to ping twice
        Cache["rssDate"] = 
            Controller.GetRSS()[0].Launch_Date;
        Cache.Add("lastRssDate", 
            Controller.GetLastRssDate(), 
            null, 
            System.Web.Caching.Cache.NoAbsoluteExpiration, 
            new TimeSpan(12, 0, 0), 
            System.Web.Caching.CacheItemPriority.Normal, 
            null);
        lastRssDate = (DateTime)(Cache["lastRssDate"]);
        mostRecentRssDate = (DateTime)(Cache["rssDate"]);

        if (mostRecentRssDate > lastRssDate)
        {
            Controller.SetLastRssDate(mostRecentRssDate);
            Cache["rssDate"] = mostRecentRssDate;
            Pinger.DoPings("Site Title", 
                "http://www.domain.com/RSS.ashx");
        }
    }
}
catch (Exception)
{
}

Notice that I’m using the Cache object to store the last date so that I don’t have to retrieve it from the database, but I am storing the information in the database so that I can retrieve it from the other server(s).  rssDate stores the most recent date from the RSS feed and lastRssDate stores the last time the ping was sent out.

I placed this code in the Page_Load event handler of the master page of my site so that it would fire whenever a page on the site was accessed.  Since the site I placed this on gets over 1000 visitors a day, I figured this was sufficient.

Like this Article? Subscribe to get every article sent to your email.

Related Post

  • Programming SEO – Cross LinkingProgramming SEO – Cross Linking As I mentioned a couple of weeks ago, cross-linking your pages within your site is one of the best ways I know to increase traffic to your site.  In fact, the week I added a plug-in […]
  • Programming SEO – Tags and KeywordsProgramming SEO – Tags and Keywords Last week I started a series on SEO from a programming perspective.  Today we want to look at one of the topics I discussed in that post in a little more detail.  Tags. […]
  • DotNetNuke Tweak FOR SEODotNetNuke Tweak FOR SEO DotNetNuke does a pretty decent job of being optimized for the search engines.  But, while tweaking one of my sites today, I realized there is one place where there is room for […]
  • DotNetNuke Modules – Creating Base ModulesDotNetNuke Modules – Creating Base Modules Now that we have DotNetNuke installed into Visual Studio we can go ahead and create our first modules. Actually, creating the modules is pretty simple. But it is even easier to do it […]
  • Programming SEO – Cross Linking TitlesProgramming SEO – Cross Linking Titles Here is another interesting way to programmatically add link juice to web pages from within your own site.  It will require that you have pages created dynamically from a database […]

About Dave Bush

Dave Bush is a .NET programmer and Certified ScrumMaster who is passionate about managing risk as it relates to developing software. When he is not writing or speaking about topics related to Application Lifecycle Risk Management (ALRM), he is an example to his peers as he develops web sites in the ASP.NET environment using industry best practices.

2 Pingbacks/Trackbacks

Awards & Certs