Archive for the ‘Featured Articles’ Category

Using the PageRank DLL in your applications (VB.NET)

To complete this walkthrough you’ll need to download the PageRank DLL.  This is included in the PageRank Checker download on the downloads page.

Extract the ZIP file.  The DLL file is in the path: GetPageRank.zip\PageRank\bin\Debug

Make a note of the path as you’ll need it later.

 

Start by opening up Visual Studio (or Developer Express etc) and creating a new project of type: Windows Application.

Then add the following controls to the main form:

Label: Text = “Website URL”

Label: Text = “Google PageRank:”

Label: Name = “lblResult” and Text = “-”

Textbox: Name = “txtURL”

Button: Name = “btnGo” and Text = “GO”

 

The next step is to add a reference to the DLL into your project.  Generally you would right-click on the Project in the Solution Explorer and select “Add Reference”.

When the dialog box eventually opens up, select the “Browse” tab and find the DLL file which should be called “PageRank.dll”, then click OK.

 

OK, double-click on the button you’ve labelled “GO” which will create an event handler for the button’s OnClick event.

I’ve provided the code in C# and VB.Net

Directions for C#

Add the following line to the top of the file:

using PageRank;

Then inside the event handler:

TGooglePR prCheck = new TGooglePR();
lblResult.Text = prCheck.ReturnPageRank(txtURL.Text);

and you’re done.

Directions for VB.Net

Add the following line to the top of the file:

Imports PageRank

Then inside the event handler:

Dim prCheck As New TGooglePR()
lblResult.Text = prCheck.ReturnPageRank(txtURL.Text)

and you’re done.

Just run the project and enter a full URL in the textbox before clicking on “GO”.  The Google PageRank will be shown in the label within a second or so.

Enjoy.

Plus I’ve done a video walthrough in C# and posted it on YouTube: http://www.youtube.com/watch?v=F9MgNVmJnro

Effect of HTTP 403-6 Error on Google

A few days ago I discovered through Google Webmaster Tools that some of my sites were unreachable by Google. In particular Google reported my homepage as unreachable and many of my sub-pages returned the same 403-6 error.

After checking my website both with various browsers and response grabbers located around the world I determined that the problem was definately not with the way I had designed the website or configured the hosting.

The HTTP 403-6 error means that an incoming request has been denied (Forbidden) because the IP address is banned or rejected in some way. Initially I tried to determine if this was because of some response error on my part; this was not the case.

I checked my server logs and could see the same errors showing up on every request that came from the GoogleBot (incidentally all requests were on the same IP). I notified my hosting provider and eventually the problem was rectified and the IP address used by GoogleBot at that point in time was unblocked.

I re-submitted my sitemaps and shortly afterwards the errors started to disappear from Google’s Webmaster Tools portal. I hoped that I had got to the root of the problem in time.

The next day while routinely checking websites I discovered that the homepages had disappeared from Google’s search results. Initially I thought that the sites had dropped on their keyword matches but “site:URL” checks showed the actual pages had been dropped.

It has taken 2-3 days for these pages to reappear in the search results and I am still waiting for some pages to come back in. Personally I found the timing to be very bad as I am trying to build Google’s confidence in my websites.

This all points to one of my main tips for SEO. It doesn’t matter about anything else if Google etc cannot see your website. Choose your hosting company carefully.

AR

Generate XML sitemap for Google

There are many sites that deal with returning a Google sitemap from .NET pages. Most of these need you to adjust the IIS settings (yes this is about Windows hosting).

There are also some that deal with creating a sitemap on-the-fly from the web.sitemap file in your project but here I’ve included the code to return an XML sitemap that conforms to the Sitemap protocol that you can submit to Google without modifying IIS – something that should interest those of you who are on shared hosting.

The ZIP download is available at the bottom of this article.

Basically if you create a blank ASPX page and clear out all the HTML elements from the ASPX page you will just be left with the <% @Page %> definition. Below is an example of the only line that needs to be in the front file (.ASPX).

For your purposes, just add the ContentType=”text/xml” section. It may NOT be necessary once you read through the page-behind code, but I’ve left it in as it doesn’t hurt.

Example:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="XMLSiteMap.aspx.cs" Inherits="XMLSiteMap" ContentType="text/xml" %>

Next you will need to put the GSiteMap.cs file in your App_Code folder.

In the page-behind code, you can then simply call the class and all the work is done for you. The code uses the filesystem (whether it is running locally or on a remote server) to generate the sitemap. It will also return the correct protocol type (http or https) and the port number if not on port 80.

I have used this method before the generate an XML file in the filesystem but since my hosting provider doesn’t allow ASPNET to write to the root directory of the site, returning the sitemap on-the-fly is the only truely automated method for this.

In the page-behind’s On_Load event:

protected void Page_Load(object sender, EventArgs e){GSitemap _siteMap = new GSitemap();_siteMap.ProcessRequestFS(Context);}

This simply passes the current HTTPContext to the sitemapping class allowing it to replace the Response with your pure XML sitemap.

I won’t go into the full code at this point because you can read through it yourself from the download. It’s worth pointing out the following however:

private string[] _Allowed_Extensions = { ".aspx", ".php", ".asp", ".htm", ".html", ".txt", ".doc", ".pdf", ".jpg", ".gif", ".xml" };private string[] _Restricted_Directories = { "App_Data", "App_Code", "admin" };

1. Put any extensions you want to be indexed in the “Allowed Extensions” array.

2. Put any directories you don’t want indexed in the “Restricted Directories” array.

Where the code pulls a list of files from each directory I initially used a file pattern, ie:

"*." + Extention

but found that some files were being indexed twice – this is because of a flaw in the framework that will return .ASPX files when you ask for .ASP files. For this reason I re-worked the code. It’s less efficient this way but it’s guaranteed to work.

The call to “ProcessRequestFS” iteratively goes through each directory adding files to the sitemap. If a directory is blocked by the “Restricted Directories” array then all sub-directories of that Directory are also blocked.

You can see an example of the output of this code by visiting: (not currently available)

On my site you may notice that I have temporary removed the optional tags from the sitemap. They are however created in the version available for download.

In particular, the priority tag is automatically down-graded for each directory further down the path that the script has to look.

There is no real error handling in this version but you can add that as necessary.

I checked with Google and Yahoo! and as far as I can see they have no problem with you adding a sitemap with the .ASPX extension.

The full code can be downloaded here: http://www.aaronreynolds.co.uk/page/Code.aspx

The full code is unavailable at the moment and will be online again soon.

If you have any problems using the code, please let me know.

AR

Return top