Scott Hanselman 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

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

September 24, '11 Comments [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

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 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 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
MVC3 ASP.NET MVC 3 (Visual Studio 2010)
MVC3Loc ASP.NET MVC 3 Tools Update Language Packs
MVC3Runtime ASP.NET MVC 3 Runtime
ID Title
AcquiaDrupal Acquia Drupal
Atlas Atlas
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:

Processing feed: ''

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'.


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 twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

This Developer's Life 2.0.5 - Typo

September 19, '11 Comments [10] Posted in Podcast
Sponsored By

Episodes 2.0.5 - Typo

Who cares about typefaces and why should you? Well, these guys do and you should start caring. Rob and Scott explore the world of reading online with one of the godfathers in the world of typeface and fonts.

In this episode we talk to Bill Hill, the bearded Scotsman who created ClearType and Geoffrey Grosenbach, notable typeface enthusiast.

I'd also like to encourage you to check out the last two episodes of This Developer's Life. We realize this isn't your typical podcast. It's not very technical, and it's not packed with information. We mean this show as an antidote to the usual technical talk shows as we try to dig more into issues and emotions that affect developers. We try to get to the center core of the developer and what makes them tick. Give us a listen and if you like the show, please review us on iTunes and Subscribe.

Download Episode 2.0.5 "Typo" here or listen online.

Also, please check out our last two shows you might have missed. We're very proud of how they turned out.

Episode 2.0.4 - Taste

2.0.4 Taste

What is taste? What is style? Do you have it? Scott and Rob have no idea what it is or how to get it - but they know it's important. In this show they talk to a designer who flexxes his good taste for a living - and a developer who is committed to spreading good taste where he can.


Episode 2.0.3 - Education2.0.3 Education

Scott and Rob discuss the value of a degree - and talk to two developers who used their passion to pull them through school and into their careers.


I hope you enjoy the show as much as Rob and I enjoy making it.

Again, big thanks to DevExpress. The bandwidth and other costs are picked up DevExpress and CodeRush! Visit them and thank them on Twitter.

This Developer's Life is brought to you by CodeRush for Visual Studio.

This Developer's Life is brought to you by CodeRush for Visual Studio.

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

New Tools and New Content - ASP.NET, Visual Studio 11 Web and .NET 4.5 Developer Preview (with commentary)

September 16, '11 Comments [48] Posted in ASP.NET | ASP.NET Ajax | ASP.NET MVC | IIS | Mobile
Sponsored By

ASPNET_vNextWhile all of you Build attendees are making me feel bad because you have a fancy Tablet and I don't (sell me yours!) the folks over here in the "Angle Brackets Team" (I'm trying out some new names. One will stick.) have been busy.

Here is a summary of all the items from our team that have been announced and shown at Build this week, all of this will be publicly available today (9/16) along with a some narrative and asides from yours truly.

They are listening

One of the things I am am personally enjoying in working daily with this build of Visual Studio is that there's dozens (hundreds) of little "mental speed bumps" that are smoothed over. A lot of thought was put into workflow and common scenarios in order to, well, get out of a developer's way.

Another constant source of happiness on my part is the team's realization that not everyone can upgrade their Visual Studio, so you can round trip your projects and solutions. I can use Visual Studio 11 Developer Preview and open a .NET 4 application, save the project, and then open it in Visual Studio 2010 and it'll just work. As it always should have. Teams can mix and match and the beta guy can  be wacky without checking in solution files that will break the other folks.

By the way, have you seen our new org chart?

Our new org chart

Big Aside: Changing how we release software

Scott Aside: It's also worth noting that while there is a bunch of stuff in the next version of Visual Studio, there's an equally compelling amount of stuff being released from the Azure/Web Team on NuGet. This gets to my LEGO analogy where we developers have more choice of what we snap together. Most importantly many things will only live on NuGet. I'm looking at the possibility of  NuGet Feed of Supported Microsoft Products. Folks sometimes assume that NuGet is a place to throw binaries up because it's convenient, but we also need a way to know if a NuGet package is actually a support product, kind of like "Verified" is on Twitter. I'm interested in your thoughts on this in the comments, or even better, in the Discussion Tab on the NuGet project site.

Shipping via NuGet is also significant because it helps level the playing field with Open Source libraries. Microsoft's open source libraries will "compete" for our developer-attention by all being in NuGet, and folks should use the ones that make them happy. If you want to use Microsoft's Ajax Minifier or any of a half dozen others, then just get the one you want from NuGet. Microsoft's won't ship out of the box. It'll be on NuGet.

Visual Studio 11 Developer Preview

A new Solution ExplorerTuesday the "Windows 8 Express" version of Visual Studio was released with the Windows 8 Developer Preview release which supports Windows 8 development. Wednesday during the keynote with Satya Nadella,  Scott Guthrie, Jason Zander  Visual Studio 11 Developer Preview and .NET 4.5 were announced. The bits are available today to the public.

ASP.NET 4.5 Developer Preview includes new core functionality like WebSockets, anti-XSS encoding, granular request validation. It also includes Web Forms improvements like model binding, support for HTML5 and unobtrusive JavaScript. And there have many performance improvements in ASP.NET when combined with Windows 8 Server can decrease startup time by 30% and reduce the memory footprint by 30%.

Scott Aside: I continue to put gentle pressure on all the teams about semantic versioning. In this case, .NET 4.5 is the right version number. It's using the .NET 4 CLR and is an additive (with bug fixes) release to .NET 4. Because it does that, it's very compatible. Your existing .NET 4 stuff won't (shouldn't) break. Check out the Target framework dropdown in this version of Visual Studio. See how you can target from 2.0 to 4.5 with the same IDE? That will be useful for corporate customers who need to develop 2.0 apps but still want the IDE improvements.
All the frameworks from 2 to 4.5 living together in a single dropdown. I never thought I'd see the day.

Visual Studio 11 Developer Preview includes new lots of new functionality including full editor support for CSS 3, full editor support for HTML 5, full editor support for JS, and many niceties like how Web Forms events can be wired up in source view, Web Forms designers can be launched directly from source view, how Live Inspector (code named "Eureka") makes editing the HTML of your document live much easier by automatically finding the HTML in your document as you select it in the Browser and much more.

Scott Aside: They've leveled the playing field across all the editors so things like regions, collapsing hierarchies, commenting, formatting, etc are all the same between CSS, JS, HTML and code. One more reason to just turn off all your foolbars and embrace the text editor and code.

You can read more about all the new features that are enabled in this release by reading the What's new in ASP.NET 4.5 and Visual Studio Web Developer whitepaper here:

NuGet 1.5 w/Dev11 Support Released

We just published an update to NuGet 1.5 that supports Visual Studio 11 Developer Preview. This allows developers on the Preview builds to continue to use NuGet with the preview releases of Visual Studio.

Note: NuGet does not support the "Windows 8 Express" release that was released yesterday. Support was just recently added to that SKU of Visual Studio and will appear in the next public preview release of "Windows 8 Express".

You can download the new release here:


There's a lot of new improvements in ASP.NET and WebForms in particular in this coming release. ScottGu is doing a series and has done these posts already:

Model Binding will be familiar to MVC folks ,as is Routing. Both features now existing in both WebForms and MVC. So much time is spent in WebForms pulling data out of the request, via Forms, or QueryStrings, or Controls. Sometimes it seems like 30% of my WebForms code is just moving data from the Request into a variable. Now I can do this:

public IQueryable<Product> GetProducts(
[QueryString("q")]string keyword,
[Control("categories")]int? categoryId)
IQueryable<Product> query = _db.Products;

if (!String.IsNullOrWhiteSpace(keyword))
query = query.Where(p => p.ProductName.Contains(keyword));

if (categoryId.HasValue && categoryId > 0)
query = query.Where(p => p.CategoryID == categoryId);

return query;

This method supports a GridView that can sort, filter by category, and search via URL. Note the use of a nullable int as well. It makes WebForms code a lot cleaner, and it's just one example.

Scott Aside: ASP.NET 4.5 is additive to ASP.NET 4, so your existing apps will run, of course, but you can just start using these new features once you're using 4.5. I've been able to "refactor via subtraction" and yank out a bunch of tedious monkey code.

One other thing I wanted to say. It's becoming clearer to me that it's less about WebForms or MVC or WCF WebAPI Services or OData or IHttpHandlers or SingalR and more about ASP.NET. I used to call mix-and-match apps "hybrid" applications, but now I'm realizing they are just ASP.NET applications. I'll use whatever LEGO piece(s) I want and you should also.

MVC 4 and Web Pages 2 Developer Preview Released

The new responsive design of the MVC4 HTML5 default templateASP.NET MVC 4 Developer Preview is the latest release of our MVC framework. This release includes built-in support for mobile sites, new, fresh HTML5 project templates as well as jQuery Mobile. It has enhanced support for asynchronous methods, and custom code generation.

Also included are Web Pages 2 (like MVC with the V and C in the same file) a lightweight framework for creating dynamic, data-driven websites. The latest version expands support for mobile devices and for integrating client scripts, and adds helpers for tasks like mapping. You can download the new release for Visual Studio 2010 and Visual Studio 11 here:

Scott Aside: Web Pages is what Rob and I used to make and I'll be doing over again in Web Pages in the next week or so. If you love Razor just want a simple site, write code, hit F5, and deploy, WebMatrix and Web Pages is a nice change of pace. Also, the fact that they were able to integrate node.js into WebMatrix is not only cool but it brings up interesting questions about WebMatrix and what is can be used for. You can do PHP on it too, you know. Hm.

WCF 4.5 Developer preview AND "Web API" shipping out of band on .NET 4 and up!

Introduced Wednesday as part of .NET 4.5, includes new core WCF functionality like WebSockets, UDP multicast, improved streaming and better async support leveraging  Tasks and C# async improvements. We continued our commitment to simplicity with a number of configuration improvements (read "reductions"), making WCF throttles and quotas work for developers by default, better manageability. The WCF Client programming model is included in .NET Core profile available to Windows-tailored app developer.

Scott Aside: I've used WCF for years, begrudgingly. It is powerful, no one would disagree, but it's notoriously complex and scary. I'm impressed with what they've done in this release because they've effectively used the infinite configurability of WCF and pluged in a re-imagination of what WCF works like in a world of REST and JSON. When it's time for WS-* and the Enterprise, that part of WCF is still there, but when you move to the RESTful open web of 2011-2012, the new Web API is clean and light, nicely integrated with ASP.NET and able to create simple and lightweight web services using things like JSON and conventions that make sense.

RIA with HTML5/JavaScript

Dinesh announced the developer preview for RIA for JS/HTML5 in his BUILD talk. It's a set of jQuery plugins that let you easily work with server data on the client. By bridging the different tiers, RIA/JS lets you quickly build rich forms-over-data applications with HTML/JQuery. The libraries are available via RIAServices.jQuery NuGet package as well as codeplex. The WCF RIA Services for Silverlight were also updated via WCF RIA Services V1.0 SP2 and WCF RIA Services Toolkit Aug 2011 update.

Scott Aside: RIA was another project that I had checked out very early on and said, meh. I'm zero for two on judging their projects because the WCF team has embraced jQuery, JSON and a more open web in a big way. I'm impressed with their efforts and open attitude. Take a look at their "BigShelf" starter project and check out how they are using jQuery to retrieve and bind, filter and sort data on the client side. Again, fewer black boxes since it's all HTML and JavaScript. Be sure to scroll down on that page as it's a complete walkthrough.

Here's a rollup of other related links for you, Dear Reader, with downloads at the very bottom.

Announcement Links

Download 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

WebMatrix and node.js: The easiest way to get started with node on Windows

September 16, '11 Comments [24] Posted in IIS | nodejs | WebMatrix
Sponsored By

Tomasz Janczuk and Steve Sanderson are having entirely too much fun. I posted just two weeks ago on Installing and Running node.js applications within IIS on Windows - Are you mad? when Tomasz and the team got node.js running rather nicely under IIS. Now they've got a nice little development environment in WebMatrix.

Cats and Dogs, living together, mass hysteria

Then, Steve and Tomasz decide to share clever thing with us. Well, let me just show you. Remember, this is all in-progress goofing around v0.5 stuff at best but the concepts are sound.

node.js inside WebMatrix. You may start freaking out now.

And then:

Node.js Express Site1 - Microsoft WebMatrix (76)

Hit Run:

Node.js Express Site running on Windows

How can you use WebMatrix to develop node.js applications yourself? With these easy steps:

Isn't it lovely when LEGO pieces snap together so nicely?

Enjoy, Dear Reader.

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.