10 Apr 2007

A Guide To Proper URL Construction

2 Comments Uncategorized

For many developers the URL Address is just a means to an end, so very little time is actually spent on creating and planning a URL that is both functional and user friendly. We have all seen the URLs that seem to go on forever, I am not going to dwell on those URLs because you can find them anywhere. I am going to go over what a good URL consists of, and some easy ways to increase your search engine ranking with your already developed application.

Search Engines Crawlers are like People

One thing that a web developer has to understand is that Search Engine Crawlers are like people. Everybody understands that if your site content is not laid out in a way that is readable, people will not spend much time on your site. The same goes for Search Engine Crawlers, if your site doesn’t conform to XHTML or at the very least HTML standards the search engine crawler isn’t going to spend much time indexing your site.

Well the very same goes for the URL of your website, if it is ugly and looks like http://somesite.com/default.aspx?a=0038383-838308380-8383&c=3&p=30203#page-2 it is very hard to determine what part of the URL changes the content displayed and what this content is actually suppose to be. I don’t even think the developer of this application could tell you. But a more friendly version of the same URL might be written like http://somesite.com/authorname/google/correct-use-of-the-url.html#page-2. Just like the content example above, the Search Engine Crawler will have an easier time cataloging the nicer URL because it actually uses real words instead of magic numbers that don’t mean anything except to the program.

3 Tips For Constructing a Proper URL

  1. Remove Duplicate URLs
    Jeff Atwood recently wrote an article dealing with multiple URLs and the effects they have on your Search Engine Ranking:

    As a software developer, you may be familiar with the DRY principle: don’t repeat yourself. It’s absolute bedrock in software engineering, and it’s covered beautifully in The Pragmatic Programmer, and even more succinctly in this brief IEEE software article (pdf). If you haven’t committed this to heart by now, go read these links first…

    With URLs there are many ways to get to a website:

    1. http://coderjournal.com
    2. http://www.coderjournal.com
    3. http://coderjournal.com/index.html
    4. http://www.coderjournal.com/index.html

    Having these multiple URLs reference the same content decreases your Search Engine Ranking, specifically PageRank is calculated per-URL. So the best idea is to do a 301 Redirect for the different patterns I listed above. In my case of Coder Journal I have URLs 2,3,4 all redirecting to URL 1.

  2. Combine Domains
    Most people don’t know but this blog has multiple domains that get you to the same point.

    • http://www.coderjournal.com
    • http://coderjournal.net
    • http://coderjournal.org

    Just like what we previously went over about Duplicate URLs the same applies to domain names. So it is wise to also do a 301 Redirect from the domains. In the case of this blog I have the .net and .org domains doing a 301 redirect to my .com domain name.

  3. Increasing Your Surface Area With Keywords in URLs
    If you do most any search on Google, you will notice that Google also highlights the keywords that show up in the URL. So a URL that looks like this http://www.coderjournal.com/2007/04/new-novell-ad-campaign-mac-vs-pc-vs-linux-continued/ is going to attract a lot more attention on keyword searches than a URL that looks like http://www.coderjournal.com/2007/04/new-novell-ad-campaign-mac-vs-pc-vs-linux-continued/

The 3 tips that I gave you above are just the tip of the SEO iceberg. However implementing one or all of these should increase your Search Engine Ranking, without effecting the functionality of your application. What more could you ask for?

26 Mar 2007

Google Pack a Computer Users Best Friend

No Comments Uncategorized

Do you hate having to go to umpteen sites just to download your essential software to get your computer running?
Do you hate then having to again go to umpteen sites again to check for software updates, and then downloading and installing them?

Google Updater Installed Software ScreenWell I have the answer for you, it is call the Google Pack. Not only does the Google Pack include a wealth of Google software it also includes many non-Google software titles such as, Skype, RealPlayer, Adobe Reader, Norton AntiVirus 2005 SE, Ad-Aware SE Personal, Mozilla Firefox, and all the software is downloaded and installed according to your preferences. And as an added bonus there is a service that runs in the background called Google Updater and it will keep all of the supported installed programs updated to their latest and greatest version. See image to the right for a screen shot of Google Updater.

So if you would like to check out the Google Pack just click the button below:


The following wealth of programs is one of the main reasons I recommend it along with Firefox on the left side of my site.

List of Software in Google Pack

  • Google Earth
  • Google Desktop
  • Picasa
  • Google Pack Screensaver
  • Google Toolbar for Internet Explorer
  • Mozilla Firefox with Google Toolbar
  • Norton AntiVirus 2005 Special Edition
  • Ad-Aware SE Personal
  • Adobe Reader
  • Google Talk
  • Google Video Player
  • RealPlayer
  • GalleryPlayerHD Images
  • Skype
08 Mar 2007

Track Cookie Usage with a Web Service via AJAX

1 Comment Uncategorized

Many of the modern and sophisticated traffic monitoring software can track everything from number of visits, where a visitor came from, what search terms were used to find your site, where the visitor came from geographically, to what type of browser they are using on what platform.

Many of the JavaScript based solutions such as Google Analytics offer much more information about the browser than ones that sit between the web and the web server such as AWStats. This is because there is much more information provided via JavaScript about the screen resolution and color depth, however the down side is that if JavaScript is disabled you don’t get any information. So it is usually a wise idea to use a combination of both Client and Server based traffic monitoring.

However one feature that they all seem to lack is tracking if a user has cookies enabled on their browser. For the life of me I cannot understand why this is the case for the JavaScript based Client side solutions. So I developed a small web service in .NET that allowed me to track this information via an AJAX call. You can accomplish the same thing with about an hour of your time and the ASP.NET AJAX Library provided by Microsoft.

First you need to create a web service called CookieSupport.asmx with the following code.

using System;
using System.IO;
using System.Web.Services;
using System.ComponentModel;

using Microsoft.Web.Script.Services;

namespace CookieTest
{
	/// 
	/// Summary description for CookieSupport
	/// 
	[WebService(Namespace = "http://tempuri.org/")]
	[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
	[ToolboxItem(false)]
	[ScriptService]
	public class CookieSupport : System.Web.Services.WebService
	{
		[WebMethod]
		public void Supported(bool supported)
		{
			using (StreamWriter writer = File.CreateText("c:results.txt"))
			{
				writer.WriteLine(@"----------------------------------------
IPAddress = {0}
Cookies Supported = {1}
Location = {2}
Browser = {3}",
				   Context.Request.UserHostAddress,
				   supported,
				   Context.Request.Url,
				   Context.Request.UserAgent
				);
				writer.Flush();
				writer.Close();
			}
		}
	}
}

Second you need to add the script manager to the body.

	<asp:ScriptManager id="scriptManager" runat="server">
		<Services>
			<asp:ServiceReference Path="CookieSupport.asmx" />
		</Services>
	</asp:ScriptManager>

Last you need to add the following script in the head of your website.

// POST cookie support of browser back to web service
function PostCookiesSupport() 
{
	var cookieEnabled = navigator.cookieEnabled;

	//if not IE4+ nor NS6+
	if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) { 
		document.cookie = "testcookie"
		cookieEnabled = (document.cookie.indexOf("testcookie")!=-1)? true : false
	}

	CookieTest.CookieSupport.Supported(cookieEnabled);
}

You may have noticed that CookieTest.CookieSupport.Supported(cookieEnabled); is the same namespace as the C# web service I listed in the first step. They took the idea of C# namespaces and translated it in to JavaScript to make it easy to remember and call.
This is facilitated though the ScriptServiceAttribute which creates a JavaScript file that is imported into your website, that is based on the methods of the WebService. You can view this generated JavaScript by visiting http://www.yoursite.com/CookieSupport.asmx/js, I have also included it below:

Type.registerNamespace('CookieTest');
CookieTest.CookieSupport=function() {
this._timeout = 0;
this._userContext = null;
this._succeeded = null;
this._failed = null;
}
CookieTest.CookieSupport.prototype={
Supported:Sys.Net._WebMethod._createProxyMethod(this,"Supported", "CookieTest.CookieSupport.Supported",false,"supported"),_get_path: function() { return CookieTest.CookieSupport.get_path(); },
    set_timeout: function(value) { this._timeout = value; },
    get_timeout: function() { return this._timeout; },
    set_defaultUserContext: function(value) { this._userContext = value; },
    get_defaultUserContext: function() { return this._userContext; },
    set_defaultSucceededCallback: function(value) { this._succeeded = value; },
    get_defaultSucceededCallback: function() { return this._succeeded; },
    set_defaultFailedCallback: function(value) { this._failed = value; },
    get_defaultFailedCallback: function() { return this._failed; }
}
CookieTest.CookieSupport._staticInstance = new CookieTest.CookieSupport();
CookieTest.CookieSupport.set_path = function(value) { CookieTest.CookieSupport._staticInstance._path = value; }
CookieTest.CookieSupport.get_path = function() { return CookieTest.CookieSupport._staticInstance._path; }
CookieTest.CookieSupport.set_timeout = function(value) { CookieTest.CookieSupport._staticInstance._timeout = value; }
CookieTest.CookieSupport.get_timeout = function() { return CookieTest.CookieSupport._staticInstance._timeout; }
CookieTest.CookieSupport.set_defaultUserContext = function(value) { CookieTest.CookieSupport._staticInstance._userContext = value; }
CookieTest.CookieSupport.get_defaultUserContext = function() { return CookieTest.CookieSupport._staticInstance._userContext; }
CookieTest.CookieSupport.set_defaultSucceededCallback = function(value) { CookieTest.CookieSupport._staticInstance._succeeded = value; }
CookieTest.CookieSupport.get_defaultSucceededCallback = function() { return CookieTest.CookieSupport._staticInstance._succeeded; }
CookieTest.CookieSupport.set_defaultFailedCallback = function(value) { CookieTest.CookieSupport._staticInstance._failed = value; }
CookieTest.CookieSupport.get_defaultFailedCallback = function() { return CookieTest.CookieSupport._staticInstance._failed; }
CookieTest.CookieSupport.set_path("/CookieSupport.asmx");
CookieTest.CookieSupport.Supported= function(supported,onSuccess,onFailed,userContext) {CookieTest.CookieSupport._staticInstance.Supported(supported,onSuccess,onFailed,userContext); }

This came in very useful for me tracking the number of users that have cookies enabled. This may come in very useful for anybody else who wants to join their client side script via AJAX with a web service. This new technology in ASP.NET has limitless possibilities of joining your existing web services with the client side browser with out having to refresh the content of your page with each and every call that needs to be made.

As always happy coding.