Scott Hanselman

RFC: New Beta.ASP.net website

October 10, 2011 Comment on this post [55] Posted in ASP.NET | ASP.NET MVC
Sponsored By

http://beta.asp.net 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 http://asp.net 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 (asp.net, silverlight.net, windowsclient.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 http://beta.asp.net.

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 (http://www.asp.net/) 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 http://beta.asp.net.

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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

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

October 05, 2011 Comment on this post [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.

Buns

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.

Back

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

Bytes

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.

Brain

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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

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

October 02, 2011 Comment on this post [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.

Development

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

Blogging

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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Hanselminutes.com: Rewriting a 5 year old VB.NET WebForms application as an ASP.NET Web Pages application with Razor

September 27, 2011 Comment on this post [24] Posted in ASP.NET | VS2010 | WebMatrix
Sponsored By

I'm planning on updating the Hanselminutes.com 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">
</asp:ContentPlaceHolder>

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"
PageSize="999">
<FooterStyle BackColor="Tan"></FooterStyle>
<AlternatingItemStyle BackColor="#F4F7E0"></AlternatingItemStyle>
<Columns>
<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}">
</asp:BoundColumn>
</Columns>
</asp:DataGrid>

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.

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

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) {
@show.ShowTitle<br/>
}
}

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)
{
@show.ShowTitle<br/>
}
}

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) {
<tr>
<td>@show.ShowID</td>
<td><a href="/@show.ShowNumber">@show.ShowTitle</a></td>
<td>@show.DatePublished.ToString("yyyy-MMM-dd")</td>
</tr>
}
</table>

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');
});
</script>

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) {
<tr>
<td>@show.ShowNumber</td>
<td><a href="/@show.ShowNumber">@show.ShowTitle</a></td>
<td>@show.DatePublished.ToString("yyyy-MMM-dd")</td>
</tr>
}
</table>

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

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' />
</object>
</audio>
}
}
}

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 http://hanselminutes.com/1 instead of http://www.hanselminutes.com/default.aspx?showID=2.

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" />
</conditions>
</rule>

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}/" />
</rule>

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" />
</conditions>
<action type="Redirect" url="{R:1}" />
</rule>

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

http://hanselminutes.com/default.aspx?showID=300

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" />
</conditions>
<action type="Redirect" url="http://hanselminutes.com/{R:1}" />
</rule>

So when this is up, the current (as of this writing) show is http://hanselminutes.com/285, 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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

RFC: Web Platform Installer (WebPI) with an offline feed mode for bandwidth savings

September 24, 2011 Comment on this post [36] Posted in Tools
Sponsored By

My wife is in the Kingdom of Swaziland this evening. If she was a developer over there and wanted to use Web Platform Installer to get Visual Studio or some large download she would have to patiently bring the bits down over 3G. If she was very well off, she might have ASDL with a maximum speed of 512kbps down, most likely with a cap. I've talked about limited connectivity in African countries and other nations (*cough* New Zealand *cough*) before on this blog and it's no fun. I've told the wife in the past that I'm happy to live overseas but I needs me some bandwidth. It sucks when tools you like don't conserve your bandwidth.

Making sure products are available and convenient for customers without a "fat pipe" is a passion of mine and I'm always the guy in the meetings at work to remind people within the Redmond Reality Distortion Field that not everyone in the world has 35 megabit fiber to their house.

We've also been trying to push for transparency and openness in all things (no more secrets, I like to say) and it usually comes down to this: They don't like to announce stuff if they aren't sure they are going to ship it. That's cool, and I get it.

But, when I saw that the folks on the WebPI team have heard you and I and told me they are working on an offline experience for WebPI today I had to share it with you, Dear Reader. Here's the deal, I'm looking at daily builds off the developer's machine. This IS NOT the final experience and this IS NOT anything other than a daily. They are looking at shipping this soon, but they told me to put lots of disclaimers. Disclaim! There it is. As this is a daily build, there are likely more questions than answers, so I'll show you how it works now, with my commentary throughout.

Web Platform Installer Offline

The problem is, of course, that the Web Platform Installer assumes that you and the 50 people at your company sharing internet are cool with downloading the same x gigs 50 times. It also assumes that your system IS connected to the internet in some way. It's a wasteful way for us to get you bits and everyone loses.

I think the ideal use case is that someone who has the bandwidth and the time downloads all the apps they want then puts them on a DVD or a network share and then all the consumers point to that offline cache. Companies could have a share or feed that's refreshed monthly, for example.

Products in WebPI have an "AppID" or Product ID. You'll need to know the AppID for the thing or things you want to install. For example, with the online Web Platform Installer if you want to install "all the web stuff" in one click, you'd use this URL http://www.microsoft.com/web/gallery/install.aspx?appid=VWDorVS2010SP1Pack.

See the "VWDorVS2010SP1Pack" part? That refers to an AppID inside of the Feed that Web Platform Installer consumes. Everything in the feed has an AppID and you can string them together. For example, you can say http://www.microsoft.com/web/gallery/install.aspx?appid=MVC to get ASP.NET MVC 3 for VS2010. You can add lots of AppIDs separated by semicolons ";" to get multiple products and all their dependencies.

I am testing a spike of an offline command line tool called wpiutil.exe but the plan is to merge it with the Web Platform Installer Command Line tool. So, even though I'm showing two tools, pretend there are one.

You can find an AppID inside the Atom Feed that the Web Platform Installer consumes. The main feed is at https://go.microsoft.com/?linkid=9767054 which isn't really discoverable, so you can use the command line tool to find what you want.

I can run WebpiCmdLine.exe /list:all and get a big list of products and applications, then collect the IDs I want to install or cache offline for later.

Current language of installers is English

--Previously Installed Products
ID Title
----------------------------------------
AppFabric Windows Server AppFabric
AppFabricSetup Windows Server AppFabric Setup
*SNIP*
MVC2 ASP.NET MVC 2
MVC3 ASP.NET MVC 3 (Visual Studio 2010)
MVC3Loc ASP.NET MVC 3 Tools Update Language Packs
MVC3Runtime ASP.NET MVC 3 Runtime
*SNIP*
--Applications
ID Title
----------------------------------------
AcquiaDrupal Acquia Drupal
Atlas Atlas
*SNIP*
Umbraco Umbraco CMS
WordPress WordPress

Scott Feedback: I told the team that I thought these AppIDs could be also on this page in the GUI. We could add "Product ID:" to screens like this?

An example Product Details page that could potentially include more data

So now I can do this:

C:\>wpiutil.exe /create-shadow /shadow-path:c:\webpicache /product-ids:MVC3;IISExpress

Loading products in webpi feeds ...

Creating shadow for following products:
MVC3
NETFramework4
WindowsImagingComponent
MVC3Installer
IISExpress

Processing feed: 'https://go.microsoft.com/?linkid=9767054'

Processing resources ...

Processing product entries ...
Processing product entry: 'MVC3Installer'.
Processing product entry: 'MVC3'.
Processing product entry: 'NETFramework4'.
Processing product entry: 'IISExpress'.
Processing product entry: 'WindowsImagingComponent'.

Done.

See how the tool got the the dependencies as well? Here's the folder structure that was created locally:

The folder structure created by WebPI that has all the installers and custom feed

Now I can point the command line tool at my new custom feed. My custom feed contains ONLY what I've downloaded. It's a subset, although I suppose a company COULD make a complete (or at least a large) shadow copy of everything and keep it on a server.

C:\>WebpiCmdLine.exe /xml:"C:\webpicache\feeds\shadowfeeds\shadow-webproductlist.xml" /List:All

Successfully loaded metadata from feed C:\webpicache\feeds\shadowfeeds\shadow-webproductlist.xml

Current language of installers is English

--Available Products
ID Title
----------------------------------------
MVC3Installer ASP.NET MVC 3 Tools Update Installer
IISExpress IIS 7.5 Express
MVC3 ASP.NET MVC 3 (Visual Studio 2010)
NETFramework4 Microsoft .NET Framework 4

Then I can install the products I want like this:

C:\>WebpiCmdLine.exe /xml:"C:\webpicache\feeds\shadowfeeds\shadow-webproductlist.xml" /Products:MVC3

Here's some of the my personal feedback to the team in no order:

  • There should be as much visual feedback as possible from the command line tool, given that it'll be run over slow networks (even 3G) so something like a (345kb of 56 megs) updating text area...
  • A way to switch the Web Platform GUI to be completely offline by pointing it to a local feed.
  • The command line tool should be smart about relative vs. absolute paths, as well as UNC, or even running your company's custom internal Web PI server.
  • Maybe consider using BITS (background internet transfer service) like Windows Update so folks could run it in the background over many days.
  • "Shadow" isn't a good name as it sounds like the Shadow Copying feature in Windows. Just call it offline.
  • More documentation on how customers can make custom feeds for their products. Just as NuGet gets libraries for Visual Studio 2010 projects, WebPI consumes feeds of MSIs and their dependencies.
  • It must be smart about resuming after a dropped connection or call and must retry corrupt downloads.
  • Group policy support so that IT Administrators could control how WebPI works inside a large enterprise and where it loads files from.
  • Should have a smart default path like c:\webpicache or .\webpicache if it's run without a full path.

Now, this is your (and my) opportunity to provide comments and suggestions to the team and affect the final direction of the product or future versions.

From what I've shown you, Dear Reader, my questions to YOU are:

  • Will this be a good feature?
  • Will it help you?
  • Is it useful or useless?
  • Is it important to be a GUI or is a Command Line good too?
  • What has been forgotten?
  • What's a "must have" and what's a "don't need?"

Discuss, they are listening!

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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

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