Archive

Archive for January, 2008

Attempting some permalink magic

January 28th, 2008 3 comments

My good friend and colleague over there in the Valley of the Sun, Tim Heuer, recently blogged to ‘respect the permalink’. This was in response to a blog post Tim came across that caught his attention entitled ‘.aspx considered harmful’. The point in contention is how file types, as part of a blog posting’s url, is a bad thing on the account if you ever switch blogging engines, you run the risk of having a different permalink than your past (and previously indexed) blog entries. Tim’s observation is that it doesn’t matter what the url looks like just as long as when you do switch blogging engines that you handle the past permalinks accordingly.

Tim uses this very (this one, the one you’re reading right now) blog as an example of … get this … the right way to handle it. Tim points out my little experiment back in the fall when I switched my blogging engine of choice from Community Server to WordPress. This was just a little experiment on my end to get a taste of using/customizing/enhancing a PHP application. Nothing more. Nothing less. However, I had this very problem pop up – how do I handle all of my old indexed content? The URLs stuffed into the depths of Google et al would be turning up 404′s left and right. Surely not the experience I wanted my readers to face.

Tim posed an inquiry of wondering how I accomplished such a task. Well, Tim… it wasn’t easy!

I have been blogging since 2003. My blog started out running on .Text and then to various editions of Community Server. A logical progression as the .Text code was ingested by the Community Server project. The team over at Telligent did a stand up job of handling the old permalinks of .Text inside of Community Server. However, moving from Community Server to WordPress, I had to come up with a way to handle the old Community Server permalinks inside of WordPress. As an example, the old .Text blog rendered it’s permalinks with an associated PostID, http://davebost.com/blog/archive/2003/11/05/145.aspx. Later versions of Community Server offered up a more customary permalink as in http://davebost.com/blog/archive/2007/06/21/walking-through-a-movie-shoot.aspx. WordPress, however, worked with a slightly different permalink pattern – http://davebost.com/blog/index.php/2007/06/21/walking-through-a-movie-shoot/, notice the index.php stuffed inside the URL. What I wanted was a clean URL of any file types – period. No ‘.aspx’. No ‘.php’. Just a standard (is it a standard?), clean permalink url – http://davebost.com/blog/2007/06/21/walking-through-a-movie-shoot.

Thankfully, WordPress comes with a plethora of plug-ins to enhance the WordPress experience. To remove the index.php from every single blog post and to prevent “locking” myself into WordPress, I downloaded and installed the ‘Remove index.php from Permalinks in IIS’ plug-in. Not one for a catchy name, but it does the trick. Now all my new posts in WordPress would follow the url pattern of http://davebost.com/blog/{yyyy}/{mm}/{dd}/{post title}.

The next challenge was to handle all of the old URLs. There are many articles on the web on using ISAPI filters in IIS or mod_rewrite in Apache to handle such tasks, however I’m running my blog on an IIS server hosted at WebHost4Life. I don’t have the ability to just dump an ISAPI filter willy-nilly on the box, therefore I needed another way.

In ASP.NET you have the ability to handle tasks before the application processes the page request through the Global.asax file. I was looking for a .PHP equivalent to the Global.asax but couldn’t find one. If something like this does exist in PHP, please contact me and enlighten me. Because my blog is running on an IIS box, I kind of cheated with my solution. There’s nothing stopping from ASP.NET and PHP handling requests at http://davebost.com/blog, so I thought to myself… “can I pre-process a page request for a WordPress blog with a Global.asax file”? It turns out, you can!

Essentially here are the steps I use in the Global.asax file to accomplish my permalink conversion magic…

  • At Application_BeginRequest and peek at the URL request. If ‘/archive/’ is present in the URL, convert the URL to our new permalink structure (http://davebost.com/blog/{yyyy}/{mm}/{dd}/{post title}).
  • Maintain a collection of PostID mappings to post titles (a reference dictionary). I created a query to my Community Server database that rendered the .NET code to create a dictionary of references between PostID and PostTitle. This is loaded during the Application_Start event in the Global.asax file and loaded into cache. This will handle the old .Text URLs, ie. http://davebost.com/blog/archive/2003/11/05/145.aspx.
  • If the URL is determined to contain a number as the file name (ie. 145 in 145.aspx), use the reference dictionary to look up the post title and build url per our template.
  • Community Server generated some unicode characters in URLs that had special characters (“:”, “?”, “-”, etc.). WordPress either ignores these special characters or use’s a hyphen (-) as a placeholder. In this case, I created a dictionary to maintain these rules. Once again, this dictionary is loaded at Application_Start and is cached. The post title is processed against this rules dictionary to handle the special characters accordingly.
  • Once the URL is converted over to the new URL pattern, a 301 Redirect is sent to notify the interested parties that this URL has “permanently moved”.

If you’re interested in this code I’d be more then happy to share it. I’m sure there are other ways to do this. This solution isn’t the most elegant, but it does the job. Or it seems to be doing the job. So much so that it seems the search engines are catching up. I tried searching for some old URLs but found that the search engines had the new URL pattern for my old blog posts. There may be some edge cases. If you encounter a 404 from a previous link, please let me know.

Thanks Tim, for calling me out. I’ve been meaning to post this for quite a while. You forced my hand and now maybe someone else can learn from my adventures.

 

Share on TwitterSubmit to redditShare via email

Windows Update offers up Silverlight install option

January 28th, 2008 4 comments

For Christmas, we bought the mother-in-law a new HP Photosmart C5280 printer to replace her old HP LaserJet 4L. She was due for a new cartridge in the LaserJet which was going to set her back $97! The decision was made to bring her printing powers to the 21st century with the HP C5280 All-in-one. The fear was that the printer was a little too fancy for her because all she needs to do is…well…print. I don’t know if you’ve looked to buy a printer recently, but you’re hard pressed to find a decent one that just prints anymore.

Anyhow… I finally got around to buying a much needed USB Hub and proceeded to install her new printer for her. As is customary every time I sit down at her computer, I ran Windows Update. I was pleasantly surprised to find that the Silverlight 1.0 plug-in has made it in to Windows Update.

silverlight_update

Notice, this is an optional update and not a required update. Microsoft is not forcing this down, however they are making it easier for you to install Silverlight. Tim Sneath posts on his blog that this move was at the behest of our customers that want to have more control in deploying Silverlight in their managed environments.

Many customers have requested help with deploying Silverlight internally, and this change will hopefully be welcomed by enterprises who want to distribute Silverlight within their organizations using their established management tools. By adding it as an optional update, enterprises can control the roll-out of Silverlight within their organizations and schedule its installation as a background task so that the perceptible impact is minimal, and ensure that end-users can view Silverlight content without requiring administrative rights to install the plug-in.

After selecting the option to install Silverlight 1.0, you are presented with the following opt-in dialog when you land on a website that is utilizing the Silverlight plug-in. Here you have option to either ‘Enable’ or ‘Disable’ Silverlight, as well as access the Silverlight license agreement.

enable_silverlight

I think this is a great move. Especially in helping our enterprise customers roll out Silverlight more effectively while maintaining the control they demand.

Thoughts?

 

Share on TwitterSubmit to redditShare via email

Event: The 2008 Microsoft Office System Developer Conference

January 16th, 2008 1 comment

image

The 2008 Microsoft Office System Developer Conference is coming to San Jose, CA on Feb. 10 – 13. This is the premier event to attend if you’re building Microsoft Office and SharePoint applications. Bill Gates, along with other leaders of the Office and Live product groups, will be keynoting the event.

There will be several tracks covering the following topical areas: Architecture, Client, Real World, Server, and Services Track. There will also be several "Unconference" sessions, contests, awards, entertainment and more.

You can visit http://www.odc2008.com for more information and to check out the track owner blogs.

Register Now and tell them your local Developer Evangelist sent you (Dave Bost; dbost@microsoft.com).

 

Share on TwitterSubmit to redditShare via email

People who are *WAY* smarter than me

January 10th, 2008 2 comments

I have to title this one under the heading of “People who are *WAY* smarter then me” just because of … well … Wow!

Chris Koenig pointed me to this video of Johnny Chung Lee using the Wii Remote and Sensor Bar to do some amazing things with virtual reality. Not only was I impressed by the technology solution that Johnny developed but his ability to explain it to someone as … well … not as smart as Johnny.

Johnny has several other Wii projects under his belt and the coolest part of it all is that he’s using C# to build these.  Awesome!

 

Share on TwitterSubmit to redditShare via email

Starting a Fire for Silverlight and the MIX University

January 10th, 2008 1 comment

firestarter_300 Back in September, we held our first SilverlightDevCamp in Chicago. There was a lot of interest from several designers/developers wanting to know about this new technology and how it’s going to play a part in building the next generation web experiences. The participants at the SilverlightDevCamp were mostly new to the whole Silverlight technology and were begging for more opportunities to learn more about this exciting technology. Silverlight is a fast paced technology and it’s difficult keeping up with the pace.

Adam Kinney, a member of the Silverlight Technical Evangelism team and SilverlightDevCamp Chicago participant, tells us of a recent event him and his team hosted in Seattle called Silverlight 1.0 Fire Starter. This event brought out interested parties for a day to learn more about Silverlight 1.0 and it’s place in today’s world of Web User Experience. Thankfully, they were thoughtful enough to roll the cameras and capture the entire event for the rest of us to enjoy. Thanks, Adam!

Silverlight 1.0 Fire Starter includes great demos and talks from the likes of Adam Kinney, Jesse Liberty, Ernie Booth, Adam Nathan, Arturo Toledo and Mithun Dhar. There is a lot of great content here for you to learn the ins and outs of Silverlight. Even better, every session is available for download in video or audio format. What better way to spend your commute then to listen to 8-hours of great Silverlight content!

These videos of the Fire Starter event is just a small part of all of the great learning material that you can find at the MIX University. MIX University contains a wealth of other great content for you to learn about technologies like Windows Presentation Foundation, ASP.NET AJAX, Gadgets, Expression, Internet Explorer Extensions (yes, IE does extensions too), Media Center, RSS, Virtual Earth and Cardspace. Wow! That’s quite a line up and a hidden gem of some great learning resources on some really cool technology.

Enjoy!

 

Share on TwitterSubmit to redditShare via email