Scott Hanselman

410 Gone - Thoughts on Mark "diveintomark" Pilgrim's and _why's infosuicides

October 10, '11 Comments [66] Posted in Blogging | Musings
Sponsored By

Developer Tools - http___diveintomark.org_ (88)I don't know Mark Pilgrim personally. I only know his work and it's excellent. I knew of him first from his Dive Into Accessibility almost a decade ago and later from his other "Dive Into" books that educated a young generation on Python, and most recently HTML 5.

Mark is alive, but online he's gone. He committed "infosuicide" last week. All of his websites are Gone. That's capital G, Gone. Not 404, Not Found, but the not-often-used HTTP Status 410. And this is where it gets concerning to me.

HTTP Status 410 states per the spec with emphasis mine:

Indicates that the resource requested is no longer available and will not be available again. This should be used when a resource has been intentionally removed and the resource should be purged. Upon receiving a 410 status code, the client should not request the resource again in the future. Clients such as search engines should remove the resource from their indices. Most use cases do not require clients and search engines to purge the resource, and a "404 Not Found" may be used instead.

As it says, most use cases don't call for removal from a search engine, but in this case, Mark literally and figuratively "took his ball and went home," no longer interested in playing.

The first major "infosuicide" of note was that of whytheluckystiff, author of Why's Poignant Guide to Ruby. No one knows why _why left, but a tweet just before he left said:

programming is rather thankless. u see your works become replaced by superior ones in a year. unable to run at all in a few more.

Perhaps one can glean some meaning from that. In a similar vein, in 2008 Mark blogged on minimalism and then before Twitter existed Mark Pilgrim blogged (almost 7 years ago this month) a microblogpost, preserved via the Wayback Machine:

It’s time for me to find a new hobby. Preferably one that doesn’t involve angle brackets. Or computers. Or electricity.

Why do I care? I'm exploring this as someone who has been blogging publically and effectively nonstop since 2002. That's almost a decade, Dear Reader. For me to leave, either willingly or unwillingly, after putting so much useful (presumably, says my ego) information out there would be one thing. But to leave AND remove all that information, declaring it Gone and asking that it no longer be indexed seems, on the surface, to be a selfish act.

I realize it costs money to keep a website up but it's typically not a crushing expense. If one wanted to retreat from online life (as I sometimes do) one could add a banner to their existing sites that says something like "I'm taking a break and teaching high school" or "I've become a non-technical ER nurse" or "I've opened a hair salon" (each has been a one-time fantasy job for me) and setup an email auto-responder. This extraction from being online wouldn't take more than a week of prep and would be perceived as a much classier - although not as dramatic - move than a disappearance hinging on an HTTP status code.

Even so, Erik Meyer quotes Mark in a 2003 post:

"Embracing HTTP error code 410 means embracing the impermanence of all things."
- Mark Pilgrim, March 27, 2003 (

That's an accurate albeit mighty metaphysical reading into the HTTP spec. Do bloggers/teachers/infopublishers have the right to leave the community? Of course. Do we have the right to control, and ultimately remove our content? Surely. But to put so much information out and to remove it seems unnecessary. Is it to much to ask to maintain ones own archive, if only for a little while?

I've always said two things. First, respect the permalink. Second, don't give bile a permalink. While a 410 isn't bile, it's not the most respectful way to disappear.

Reading into Mark's blog, it's obvious that being on the web didn't feed his spirit. It does leave one to wonder, when you pass on, will you be mirrored or just 410 Gone?


The requested resource /
is no longer available on this server and there is no forwarding address. Please remove all references to this resource.

I truly wish Mark all the best in his disconnected life, as I do anyone else who wants to disconnect. If they come back, we'll be here.

Mirrors of Mark "diveintomark" Pilgrim's Work

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

RFC: New website

October 10, '11 Comments [55] Posted in ASP.NET | ASP.NET MVC
Sponsored By Before I worked for the ASP.NET team as I do now, I worked for MSDN. While I was over there, part of my time was spent working on the team. I led the charge to move the site over to Umbraco, and we did. Over the last two years, we have continually made improvements to the .NET (,, sites. In July, the MSDN team announced the release of a new Silverlight site, and today I'm happy to announce the Beta launch of a redesigned ASP.NET website at

This redesign is still a work in progress, but we wanted everyone to see where we are heading with not just a new look and feel, but also improved organization and navigation that will hopefully make content easier to find. We'll be collecting feedback on UserVoice.

What's new with the redesign

You'll notice that the top-level navigation is similar to the current site ( to keep the familiarity, however we have significantly improved the site design and navigational framework around Learn and Community content in an effort to make it easier to discover and find information on the site. The issue is that there's piles of great content on the site but it's hard to find. Here are some highlights of the redesign:

  • A newer Information Architecture (IA) that scales with different types of content. Trying to get you somewhere useful quickly.
  • Content organized into relevant topic areas (Overview, Videos, Tutorials, etc.) to make information easier to find and to learn a technology.
  • Improved on boarding experience – Developers new to ASP.NET should find it easier to get started and download what they need.
  • Important Samples and Tutorials are positioned prominently in the structure of the site so that they are easier to find.
  • Textual Tutorials are as important as videos - We've heard people want text tutorials more than videos, so we're finding balance between these two kind of content.
  • Improved Social Integration – Community info, pulling from Twitter, Facebook and blogs.
  • A less cluttered user experience to get you where you need to go in fewer clicks.
  • Open Source and Samples - We're looking for new ways to showcase great open source projects and excellent samples.

Next Steps

Not all the content and features are in place yet! The ASP.NET Website team will continue to iterate over the information architecture, layout, and content (with lots of new video and text content) in the coming weeks, and we are targeting to launch the final site by the end of November.

I know, more than anyone, that the #1 piece of feedback has been that folks don't like the ads. You don't need to tell me, as you're preaching to the (powerless) choir. Instead, make yourself heard - both positive and negative - at the ASP.NET Website section of our User Voice site.

I hope you like the site and find it useful. It's at

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Brain, Bytes, Back, Buns - The Programmer's Priorities

October 5, '11 Comments [70] Posted in Musings
Sponsored By

My office, which I am very happy withI recently said something that ended up making the rounds on Twitter:

"If you're a developer, you need to spend money on a great computer, an awesome monitor, a fantastic chair and a good bed" - Scott Hanselman

This convenient 140-character-friendly statement could be misconstrued, I suppose, as me saying that good developers need to spend money on expensive gear. That's not my message. I'm saying that you need to invest in your tools.


I was listening to a designer friend recently agonizing over the purchase of a US$700 chair. I realize that everyone makes different amounts of money depending on where they live in the world, but bear with me. This designer spent months trying to decide if this chair was a good idea. "It's so expensive! Should I spend that much?”

Now, we're not talking about jewelry, or video games, or fancy pants. We are talking about a chair that is going to be sat on while work is done for hours a day for at least a few years. Figure 50 weeks a year, for 3 years (at least) for 5 hours a day (because these are round numbers) that's at least 1250 hours in the first year (and more likely much more) and 3750 if it lasts the 3. That's a 19 cents an hour for a comfortable butt. Invest in your own ass.

I don't regret my purchase of a Herman Miller Aeron Chair one bit. The best part is that I bought it for myself, with my own money over 5 years ago. Every day I own it, I enjoy it, and my cost of usage per day goes down.


I spent a decent amount of money on a very nice mattress as I've got Programmer's Back. I'm consistently surprised when I talk to developers who have cheap (meaning, low quality) mattresses and cheap chairs and they complain about pain. A programmer in pain is a lousy programmer. To quote Wu Tang Clan, protect ya neck. Don't skimp on your sleeping quarters.

Physical purchases aside, it's also crucial to invest in your back with things like yoga, stretching and regular exercise. When you are using something eight hours a day for week after week, do the research and invest in that thing. You're flat on your back unconscious for a full third of your life. Give that amount of time the respect it deserves and do what's right for your body. One of the essential tools is a quality bed. I enjoy investing in a new computer but only recently realized that a utilitarian purchase like a great mattress is just as valuable and just as life-changing.

I also have a height adjustable desk (a Steelcase Series 7) which I enjoy. I wouldn't have thought twice about purchasing this desk on my own, but with enough visits to a chiropractor turns out these are easy to come by. It's motorized and has presets so it's easy to set and switch between seated and standing positions. If you think one would be helpful to you, talk to your HR department and request an ergonomic evaluation. Can't hurt to ask, but it is guaranteed to hurt if you don't.s


Ya, I couldn't just say "computer" and screw up a potentially killer alliteration. Surely you understand, Dear Reader. I hate seeing people suffer with crappy hardware. I went back and forth with a gentleman on Twitter running a 4 to 6 year old Mac who felt that I was advocating or implying that one must have awesome hardware to be a good programmer. That wasn't my intent, but this is. If you are waiting for your computer, you are wasting time. Forget about religious arguments, I don't care if it's your operating system, your text editor, or that spinning rust you call a hard drive. If it's making your wait, swap it out.

Start by getting an SSD. The fellow on twitter with the slightly older hardware had an SSD in the machine. Everyone can use an SSD. There are only so many life-changing hardware purchases left in the world. Treat yourself. They are, memory, SSD, monitor.  No matter what OS you are running, have 4 gigs of RAM at least. You can get little SSDs for under US$100 these days and decent sized ones for $200. I pulled the trigger on a 256 gig OCZ Vertex and even if it lasts just a year, it's just $2 a day for the kind of silent joy that only a saturated PCI bus can give. Every day after a year it lasts (it'll likely last a few) it gets cheaper to have owned it.

Get whatever size or number of monitors that makes you happy. I like three monitors. For laptops, I like a 15". Some folks do great on a 13" LCD but others prefer something larger. My point is, if you HATE your monitor situation, change it. You're worth it and it'll make you more productive.

And, as always, if you have Programmer's Hands, consider your keyboard and mouse. While I realize that many of you insist and persist on using a standard straight keyboard for typing even in spite of the obvious anatomy, the most important thing is to listen to your body. If your desktop set works for you, awesome. If not, get one that supports you and the way you work.


Books, classes, experience, and challenges all push your brain. I often tell the story of the senior developer who has 20 years experience. The problem is it's the same year of experience, twenty times. Somewhere in year 5, or year 14, you'd think this developer would notice this and break out. What I'm saying is that not only should you as a programmer listen to your body, you should also listen to your brain. If your tool is dull, consider consciously what you can do to sharpen the saw.

When I speak to user group meetings or regional conferences and code camps, I'm always sure to tell the attendees something like this:

 "You're already in the top tier of developers just by showing up here tonight. I don't know how talented you are, how much experience you have, but you showed up. You're putting yourself out there because you care to improve. Thanks for caring."

You should give yourself credit for simply being conscious. Not conscious as in 'a living entity' but conscious as in 'paying attention to your journey.' If you are conscious, you're ahead of the pack. We get into trouble when we aren't paying attention. Time goes by and one wakes up years later with no new experiences, no new knowledge, essentially treading water with no inertia. Sometimes just waking up and paying attention is the catalyst one needs to make a change. Every new day is an opportunity to turn it around. Don't feel bad about taking that class, buying that new book, or starting that new mentoring relationship. Get them and put them in your brain - they'll be yours forever.

There's this wonderful story that comedian Paul Reiser told Marc Maron on Marc's podcast. Paul met the actor Peter Falk and asked him if there was a secret to writing a movie script. Peter Falk said "get some paper, put it in a typewriter, type FADE IN...and keep typing."

It's surprising how that answer also works when someone asks me how to succeed in programming. Be conscious, take care of yourself, invest in your tools, and do the work.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

The Sweet Spot of Multiple Monitor Productivity: That Magical Third Monitor

October 2, '11 Comments [85] Posted in Musings | Productivity | Remote Work
Sponsored By

Al Gore with Three MonitorsI finally took the time to install a monitor bracket this evening to support my center Dell 30" monitor. Installing a monitor bracket is one of those nice little things you can do to really spruce up your workspace. I had been avoiding it because I though it would be expensive but I found a bracket that would support 50 pounds for under $40. It was easier to install than I thought and I'm considering installing two more to support my other two monitors.

Yes, three. After blogging about multiple monitors for more than eight years (!) and going as far as hooking up five monitors, I've decided that three is the real sweet spot for productivity. Any more is overkill and any less cramps my brain. I admit five was insane. Fun, but insane.

I've always wanted more than one monitor. I remember sometime in the mid-eighties being thrilled when I discovered that I could install a monochrome "Hercules" card alongside my existin  g VGA card and type 'mode mono' from the DOS prompt while running Windows, Desqview or OS/2 and effectively run command line batch processes on one monitor while doing Windowy stuff on the other. This was 25+ years ago and I've never looked back.

Three really old CRT monitorsI've said before on Twitter, and I'll say it again, if you're a developer you need to spend money on a great computer, an awesome monitor, a fantastic chair and a good bed. And food. But the other stuff first.

Bill Gates has three monitors, Al Gore does, Larry Page does. Even Jeff Atwood. ;)

Many years ago Darrell Norton moved everyone on his development team to two monitors from one with amazing results:

After multiple monitors were introduced:

  • Productivity in lines of code per day increased 10%.
  • Defect levels decreased by 26%.

The New York Times said this about multiple monitors in 2006:

Adding a second monitor turned out to be the easiest, most cost-effective and significant improvement in my work since I replaced my modem with high-speed cable.

It's true. Once you get more than one monitor, you can't stop until you get to three.

Why Three Monitors and not Two?

I think three monitors is the perfect number because the center monitor is where your primary work happens. I usually run Visual Studio or my blogging software on this monitor. The second and third monitors are like rear view mirrors in that they are about 30 to 35 degrees angled in a wrap-around configuration and I glance at them for information while I work.

For example, here's some typical scenarios with me and my three monitors.


Left Center Right
Documentation/PDFs/Browser Development IDE, Text Snippets Target App Browser, Application being Debugged


Left Center Right
Browser with articles being referenced Windows Live Writer (blogging app) NetFlix, Hulu

Deleting Email

Left Center Right
Calendar Outlook Mail/Gmail Twitter/Facebook/G+

Without three monitors, you will be task switching, and I maintain that it's always going to be easier (read: lower effort) to glance to the side or turn your head than it will be to ALT-TAB and switch to the other apps. The more apps you run the more you'll be ALT-TABbing around.

I actually find with Windows 7 and three monitors that I use WINKEY+LEFT ARROW or WINKEY+RIGHT ARROW to move applications left and right on a single monitor or between monitors with SHIFT+WINKEY+ARROWS which means nothing is every obscured. That's the key with multiple monitors.

When using computers, out of site isn't out of mind. If it's not visible on the screen then it's you that has to store it. I propose that the amount of your memory that's used to keep track of what apps are running and what state they are in is less with multiple monitors.

Installing a Bracket

Installing bracket was somehow intimidating to me. Turned out I just needed to make sure that the bracket was exactly positioned such that the bolts went into the center of the stud. I had laser stud finder and used blue painters tape to mark off the edges. I used a small level to make sure it wasn't torqued, although since the monitor bracket I got supports rotation there's more room for error than I realized.

Then I was concerned it wouldn't support the weight a 30" Dell Monitor. Turns out that this "giant" 30" Dell Monitor is actually only 25 lbs without the stand. The bracket can support 50 lbs so I had lots of room for error there as well.

Seems there was really no reason for me to be concerned about installing a bracket. I debated using a desk mounted bracket, but my desk is chrome and glass and won't handle any kind of clamp.

The only downside to this operation and the bracket is that it only moves horizontally (with 15 degrees of vertical tilt. So, if I get another desk or change the height of this desk, I'll have to move it.

 Multi Monitor BracketsMulti Monitor Brackets

I have another motorized up/down standing desk to the right of my main workstation, so when I get tired of sitting I can move over to the other desk. That desk has a fourth monitor (it's disabled in my current configuration) that I often hook my laptop up to. That way, even if I'm at the standing desk using my laptop, I've still got a second large monitor.

The Result

Here's my setup as I sit in my chair. That

Three monitors is love

Here's a cheesy panorama of my setup I as swivel in the chair 180 degrees. The white table is motorized so I can sit and stand. It has another 24" HDTV/monitor with a Cisco Umi Telepresence system connected to it. I use it for LiveMeetings, NetFlix, Xbox or Cisco/Skype.

Panorama of my setup

I just can't think of any reason why a developer shouldn't have at LEAST a second monitor. LCDs are plentiful, low power and inexpensive. Most computers and laptops can run a second monitor and even a $100 video card can run three monitors.

Do you run multiple monitors? Why?

You don't? Why not?

Related Links

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb Rewriting a 5 year old VB.NET WebForms application as an ASP.NET Web Pages application with Razor

September 27, '11 Comments [24] Posted in ASP.NET | VS2010 | WebMatrix
Sponsored By

I'm planning on updating the website to look more modern and look more like this newly redesigned blog. Until then, one of the things I wanted to try was to update the application with some simpler code. The Hanselminutes podcast website is running the same VB.NET WebForms application it was on the day I started the show in January of 2006 (almost 300 episodes ago!)

Sure, the app runs fine and there's no real reason to update it, but I wanted to see how quickly I could do it and if the code felt cleaner. I'll probably do a post where I update this .NET 1.1 WebForms app to .NET 4 and show how to maintain it. In this case, I'm updating it to Razor just because it sounded like fun. No other reason.

There's a few requirements I need to make sure I don't miss:

  • I'd like a new URL scheme. Currently showid is the database, not the logical "show id." Rather than
  • I can't break any existing links, so I want to HTTP 301 redirect from the old style to the new style.
  • I'll keep the look and feel now, but update it after.
  • Folks shouldn't notice the difference.
  • I need to use the existing wacky 2004 database, it's tables and stored procedures because all of Carl's existing backend administration systems feed into it.

But, it's such a basic application, it's basically a bunch of for loops. So, here's what I did tonight.

UPDATE: Check out the updates below as I was using inline SQL when there was no reason to! Very cool stuff in the Massive micro-ORM that I wasn't taking advantage of. Rob Conery has done a post as a result of my foolishness.

Importing the layout

I started in WebMatrix, although I could have just as easily used Visual Studio. I created a new "Starter Site." I took the existing ASP.NET WebForms application's Hanselminutes.master and copy/pasted it into the new ASP.NET Web Pages _SiteLayout.cshtml.

I then added a RenderBody() call where my WebForms application's master page had a ContentPlaceholder:

<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

I added in the existing CSS and Scripts and that got me here. A "hello world" equivalent:

Hanselminutes - Step 0

Then, I copied the Default.aspx ASP.NET WebForms code into Default.cshtml. This ASPX file has lots of server side WebForms controls like this:

<asp:HyperLink ID="hPermalink" Font-Bold="True" Text="Permalink" runat="server"/> 

But since Web Pages doesn't process any of those, they are literally ignored and sent across as if they were HTML markup. They aren't valid tags so the browser ignores them. That gets me here. More is laid out but there's no data behind it, of course.

 Hanselminutes - Step 1

Next, I need to get to the data.

Getting at the Data

I can get at the data in a number of ways, but I like lightweight and easy so I'm using Rob Conery's "Massive" micro-orm. It's 500 lines of code, so that's nice.

UPDATE: Rob Conery pointed out that everyone thinks that Massive and micro-ORMs like it require inline SQL. That they just turn table rows into objects. Turns out I was using Massive in an OK way, but not the easiest way. Note below as I've added before and after details.

There's a good discussion of WebMatrix.Data, WebMatrix.Data.StronglyTyped, Massive, and Simple.Data over at Mikesdotnetting. They are all very similar. Use the one that makes you happy. Also look at Dapper from Sam Saffron and friends and check out my Massive vs. Dapper Podcast.

The easiest page to do first is the Archives page. It's a for loop of links, so a good place to get started.

In WebForms the archives uses a DataGrid like this:

<asp:DataGrid ID="dgArchive" ForeColor="Black" GridLines="None" CellPadding="2" BackColor="#EFEFDA"
BorderWidth="1px" BorderColor="Khaki" Width="100%" runat="server" PagerStyle-Visible="false"
AutoGenerateColumns="False" ShowFooter="false" DataKeyField="ShowID" ShowHeader="False"
<FooterStyle BackColor="Tan"></FooterStyle>
<AlternatingItemStyle BackColor="#F4F7E0"></AlternatingItemStyle>
<asp:BoundColumn DataField="ShowNumber" Visible="True"></asp:BoundColumn>
<asp:HyperLinkColumn ItemStyle-ForeColor="Black" DataNavigateUrlField="ShowID" DataNavigateUrlFormatString="default.aspx?showID={0}" DataTextField="ShowTitle"/>
<asp:BoundColumn DataField="ShowID" Visible="False"></asp:BoundColumn>
<asp:BoundColumn DataField="DatePublished" HeaderText="Date" DataFormatString="{0:yyyy-MMM-dd}">

There's some color alternating going on, hard-coded colors, kind of cheesy, and some columns for the data. It's a half-decade old. I didn't write it. But as developers we inherit old code all the time.

The Massive ORM needs a connection string in the web.config, so I'll put one there.

<add name="hanselminutes"
connectionString="Data Source=yada yada yada"
providerName="System.Data.SqlClient" />

We've got a table called "Shows," so I need to let Massive know about it.

using System;
using System.Collections.Generic;
using System.Web;

public class Shows : DynamicModel
//you don't have to specify the connection - Massive will use the first one it finds in your config
public Shows():base("hanselminutes")
PrimaryKeyField = "ShowID";

Next, I'll reuse the same SQL Query used in 2006, except now with Massive. I'll just see if I can get the titles first with inline SQL.

dynamic tbl = new Shows();
var shows = tbl.Query(@"SELECT ShowID, DatePublished, ShowTitle, Description, Enabled, ShowNumber
FROM Shows
WHERE Enabled = 1
ORDER BY DatePublished DESC");

foreach(var show in shows) {

Cool, that works. But I've got inline SQL here and it's, well, inline SQL. Rob points out that Massive will let you use the Jon Skeet-designed named parameter syntax such that I can just do this and the same result as the inline SQL! I'm such a goof for forgetting this.

show = tbl.Find(Enabled: 1, orderby: "DatePublished DESC");

Ok, just to be clear, here is the whole thing again, except with smarter use of Massive.

dynamic tbl = new Shows();
show = tbl.Find(Enabled: 1, orderby: "DatePublished DESC");
forch(var show in shows)

Is nice, yes? I'll flesh out the table. Yes, a <table/>. Cause, it's, like, a table.

<table id="archives">
@foreach(var show in shows) {
<td><a href="/@show.ShowNumber">@show.ShowTitle</a></td>

Notice the href="" for the show is the ShowNumber, not the ShowID. It doesn't point anywhere yet, but I'll figure it out later.

Before they were doing some server side alternating color stuff. I need to update the CSS at some point, but since I'm redesigning soon, I'll just do it with jQuery on the client side, it's easier then the server-side if and gets the same result. Again, I'll change the template when I do the redesign.

<script type="text/javascript">
$(function() {
$('#archives tr:odd').css('backgroundColor','#EFEFDA');
$('#archives tr:even').css('backgroundColor','#F4F7E0');

Now I've got this page done, without the links hooked up. Nice and easy.

The complete Hanselminutes podcast archive - step 2

Here is the whole Archives page so far:

Layout = "~/_SiteLayout.cshtml";
Page.Title = "The complete Hanselminutes podcast archive";

dynamic tbl = new Shows();
var shows = shows = tbl.Find(Enabled: 1, orderby: "DatePublished DESC");

<table id="archiveTable" width="100%">
@foreach(var show in shows) {
<td><a href="/@show.ShowNumber">@show.ShowTitle</a></td>

<script type="text/javascript">
$(document).ready(function() {
$('#archiveTable tr:odd').css('backgroundColor','#EFEFDA');
$('#archiveTable tr:even').css('backgroundColor','#F4F7E0');

I can refactor the data access into a helper class and generally tidy up, but you get the idea.

On the home page I want to get the most recent show first using using inline SQL, that is, the LAST show:

lastShow = tbl.Single(@"SELECT Top 1 ShowID, DatePublished, ShowTitle, Description, Enabled, ShowNumber 
FROM Shows
WHERE Enabled = 1
ORDER BY DatePublished DESC").First();

And then again using Massive's syntax:

lastShow = tbl.Single(Enabled: 1, orderby: "DatePublished DESC");

At this point, it's easy to setup the home page by just sprinkling some Razor could around the original HTML template. I'm replacing <asp:Label> and <asp:Literal> with @lastShow.ShowID and things like this. Here I'm calling an existing Stored Proc and getting the filename and location then building an HTML5 <audio> element for all the MP3s.

var files = tbl.Query("GetFilesByShowID @0", lastShowID);
foreach(var file in files) {
var filename = file.WebFilePath + file.FileName;
if (filename.EndsWith(".mp3")) {
<audio width='200' height='30' controls='controls' preload='auto'>
<source type='audio/mp3' src='@filename' />
<!-- Flash fallback for non-HTML5 browsers without JavaScript -->
<object width='320' height='240' type='application/x-shockwave-flash' data='flashmediaelement.swf'>
<param name='movie' value='flashmediaelement.swf' />
<param name='flashvars' value='controls=true&file=@filename' />

Then, just 20 minutes of changing a bunch of asp:Controls to @lastShow.Something syntax and I was on my way. It's not pretty, but it's identical in functionality to the existing WebForms version.

Hanselminutes - Windows Internet Explorer (82)

Changing URLs

The only thing left is to make it so my URLs look like instead of

There's lots of ways to do this, but the simplest is to take advantage of the URL rewriting that's built into IIS7. While i'm in there, I'll add a total of three rules.

Tiny URLs with just Number

This rule will take /123 and rewrite (not redirect) to /?showNumber=123. Because I'm redirecting such a "greedy" URL, it's important that I used the constraint of \d+ to just get numbers.

<rule name="number">
<match url="(\d+)" />
<action type="Rewrite" url="/?showNumber={R:0}" appendQueryString="false" />
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

Default Document to /

This rule will take /default.aspx and make it /.

<rule name="Default Document" stopProcessing="true"> 
<match url="(.*?)/?Default\.aspx$" />
<action type="Redirect" url="{R:1}/" />

Remove .ASPX extensions

This rule will change things like /archives.aspx to just /archives.

<rule name="RewriteASPX">
<match url="(.*).aspx" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<action type="Redirect" url="{R:1}" />

But what if someone visits a link with a database ID, NOT a ShowID, like

Given a URL like this, I'll look up the show by showID, get the correct show number and then just redirect to /280 (the right number, given an old database ID of 300):

Response.RedirectPermanent("/" + lastShow.ShowNumber);

With these small changes in the web.config, plus one line of code, I'll have the same URL structure as before with 301 Permanent Redirects to the new structure that the rest of the site uses.

I'll also add one last rule to remove www. from the front of the URL which will make tweeting shows by ID nicer:

Remove www. and canonicalize domain name

<rule name="Cannonical Hostname"> 
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^hanselminutes\.com$" negate="true" />
<action type="Redirect" url="{R:1}" />

So when this is up, the current (as of this writing) show is, nice and clean.

I haven't put the new site live yet, but I'll do some more testing and do it this week. It took about two hours while watching Breaking Bad on NetFlix to convert this five page VB.NET ASP.NET WebForms application to ASP.NET Web Pages, and I'm well positioned now to make database changes as well as change the template for a redesign. More importantly, I had fun.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.