Google+

ASP.NET MVC, What about SEO?

I've started working the the latest preview of the ASP.NET MVC framework. I'm completely converting one of my sites, because learning by _doing _is typically the best way. Unfortunately, I've run into some alarming SEO (Search Engine Optimization) issues with this new paradigm (or more specifically, the Microsoft implementation).

Duplicate Ducks!

Duplicate Content

Duplicate content is a major issue. If a search engine (Google, which we're primarily concerned with) finds multiple identical pages, it could be seen as a spam technique. Google likes original content, and penalizes duplicate content.

The problem is that the ASP.NET MVC default routing is too forgiving. If I have a page with this address: "/controller/action/id", the routing engine happily serves it up at "/controller/action/id/". There is no reason to not be strict on this. In ASP.NET WebForms, if you forget the trailing slash, it will automatically perform a 301 (permanent) redirect to the version with the trailing slash.

ASP.NET MVC has a bug (I'm calling it that) that won't let you define a URL as requiring a trailing slash. Below, I've defined a route as a sample. In the URL to match, I have a trailing slash. In the routing code, the trailing slash is removed when it's added to the routing table. This also has the side-effect of generating the URL's without a trailing slash.

routes.MapRoute(
    "Legacy-Firefox",
    "Firefox-Extension/",
    new { controller = "Home", action = "Firefox", id = "" } );

Since routes can be configured to reuse actions and controllers, it makes more paths to follow. If I again use the route defined above, I end up with all of these valid addresses that could potentially be linked to and indexed:

  • a.com/Firefox-Extension
  • a.com/Firefox-Extension/
  • a.com/Home/Firefox
  • a.com/Home/Firefox/
  • a.com/Home/Firefox/anythingyouwant

If you're lucky, Google won't penalize duplicate content. However, if Google indexes the same content using multiple URL's, you won't get the benefit of focusing the PageRank. A similar situation occurs with you have a site that can be addressed like "cnn.com" and "www.cnn.com". They counted as separate pages, that end up competing for good rank.

Legacy URL's

I'm sure there is a large group of people that are anxiously awaiting to take advantage of the new MVC style development. Many of them will undoubtedly have existing URL's they want to preserve.

There are a couple of ways to handle this issue. The search engines would prefer that your URL's simply remain the same. This is possible, but requires some fancy routing. The SEO community highly recommends this approach (with good cause).

Another way to handle it is to adopt the new REST style URL's that typically make the most sense with an MVC approach: "/controller/action/id". Then, setup 301 redirects from the old addresses to the new one's. This article discusses the technical details. In theory, this should be the best scenario. However, Google themselves say to get the incoming links pointed to the new addresses ASAP. The truth is, this solution sucks. I've actually done this with a site. It was search engine suicide for a couple of months. I eventually got my old position back, but lost a significant amount of revenue because of it.

Yet another way that I found is to set up multiple routes so that the content is accessible with both the old and new addresses. If you've been paying attention, you'll know that this counts as duplicate content, and is very, very bad. I was in shock when I found this approach being advocated.

Conclusion

I'm not saying the routing system is completely wrong, I just think it would be set up so that the easy way of migrating a site is the correct way, or as close to it as possible. I don't want to have to write custom routing. At the very least, come up with a way to designate that a particular action has a single path (and cancel out additional paths in other routes). It would also be nice if there was a way to use the old style urlMapping section in the web.config for legacy URL's.

If I'm completely wrong about how the routing works, let me know. It's difficult to find good information (which is understandable right now), and I'm admittedly still in an early learning stage.

Like this post? Please share it!

See a mistake? Edit this post!

Vista actually is pretty good, honest

I know that Microsoft doesn't need anyone defending them, but I think that the series of events surrounding Vista were certainly not ideal. I've highly anticipated every new release of Windows, and Vista was no exception.

Vista Logo

Watching the progress of Vista, I couldn't help being disappointed. Vista was supposed to change the world. There would be an amazing new file system, a cutting edge graphics system, and .NET driving many of the core functionality. But one by one, the features got neutered or disappeared completely.

When it was released, the bad hype had already nearly killed it for me. Then I installed it in a virtual machine and learned what a pile of crap it really was. It took minutes to boot, and the UI was barely usable. Every few seconds I would get security prompts. I was done with this OS for a long time.

Fast forward to Windows 2008. I started reading great things about how this OS made a great desktop OS. At the core, it's Vista SP1, but with much of the crap removed. I tried it out, and loved it. I had a few issues with incompatible drivers, but that's expected when using a just-released 64-bit OS.

Then, Vista SP1 was released, and most of the cynics said it was "decent". Time had helped fix the driver issues, and SP1 addressed specific pain points. Eventually I got around to installing Vista SP1 (64 bit) over Windows 2008. I was amazed. Nearly all of the drivers were already included. It was fast, and some of the new features, while not life changers, were a boost to my productivity none-the-less.

Recently, I purchased a new laptop. It's shocking what you can get for a mere $650. It's a 14.1" HP (dv2910us) with 3GB RAM, 2GHz Core 2 Duo, 250GB hard drive, 802.11n, DVD burner, and even a built-in removable remote control. Of course it included a license for Vista. HP includes a shocking amount of crapware, so I reinstalled Vista from my MSDN media. One major improvement over XP is that your OEM key works with MSDN media. That means I can actually use the key that was on the sticker of the laptop! Thank you Microsoft (and it's about time)!

It runs great on my laptop, and I've had no complaints whatsoever. In fact, I think I've had less issues than if I was running XP. Much to my surprise, a few days ago I get a prompt to install updates. The update in the list was SP1. Yes, that's right, I wasn't even using SP1. Maybe Vista was bad when it came out, but I think the horsepower of modern computers combined with finally decent driver support erases the bad history.

Vista Copy Dialog

I'll sum up what I love about Vista over XP in one paragraph. Integrated search from the start menu rocks, and I use it constantly. I also love the new copy dialog, which tells me the actual speed of file transfers. As far as 64-bit support, I've been very impressed. It's very possible to run the 64-bit version and have a decent change of all of your devices working as expected. This is a must since typical new high-end computers are going to start going over 4GB RAM soon (if they haven't already). There are even hard to find features that are very nice. When you copy a folder over another folder, it actually gives you a reasonable set of options, as well as enough information to make a decision about merging, overwriting, or even renaming them.

Vista UAC Dialog

Now what about UAC? You know, the feature that pops up an annoying dialog every 5 seconds? Well, if you run your computer as a local administrator (like you did in XP), you'll rarely see them. I actually appreciate them because it does make your computer safer.

Conclusion

Make up your own opinion about Vista and give it a try. It's mature enough that I recommend it to my tech friends. I was just as apprehensive as everyone else, but I'm glad I made the switch. In case you're wondering, no Microsoft hasn't paid me, but it sure would be nice :-).

Like this post? Please share it!

See a mistake? Edit this post!

Screencast - Unit testing with real DataSets

As I've mentioned before, I wrote a small utility for running a SQL query, and returning the results as an XML serilialized DataSet.

I created a quick screencast to demonstrate how you go about using this utility. I'm new to screencasts, so don't expect a high production value!

image

You can check out the screencast here!

Let me know what you think in the comments!

Like this post? Please share it!

See a mistake? Edit this post!

Jason Young I'm Jason Young, software engineer. This blog contains my opinions, of which my employer - Microsoft - may not share.

@ytechieGitHubLinkedInStack OverflowPersonal VLOG