Scott Hanselman

ASP.NET MVC3, WebMatrix, NuGet, IIS Express and Orchard released - The Microsoft January Web Release in Context

January 13, '11 Comments [35] Posted in ASP.NET | ASP.NET MVC | IIS | Microsoft | NuGet | Open Source | VS2010 | WebMatrix
Sponsored By

image At PDC10 last November I did a talk on the "Unnamed Package of Web Love", showing ASP.NET MVC3 and Razor Syntax, the NuGet Package Manager, as well as SQL Compact Edition and a little "Entity Framework Magic Unicorn." I make up my own names when I don't like what Microsoft names things, as you may notice.

Today Microsoft announced the (actual, final, honest) releases of:

  • ASP.NET MVC3 with Razor
    • Lots of new features, the new Razor syntax, more extensibility hooks, new JavaScript features, better validation, easier caching, better dynamic support, and lots more.
    • This includes the NuGet package manager and the NuGet gallery is also in early beta at for folks who want to create and publish their own packages)
    • MVCScaffolding
      • Remember all that fun we had with the scaffolding experiment at PDC? Well, my teammate Steve Sanderson has taken the prototype up to version 0.8, and it's pretty fabulous. Go read his blog post, then enjoy "Install-Package MvcScaffolding." You can scaffold views, controllers, repositories, database contexts or even make your own custom scaffolder. Look for more built on scaffolding from Steve and I in the coming months.
    • Updated Beginner Tutorials for ASP.NET MVC 3 in both C# and in VB
  • NuGet
    • NuGet is a package manager for .NET. It ships with ASP.NET MVC, but you can go get it separately if you like. Installing open source libraries is as simple as "install-package elmah" - it's great fun.
  • WebMatrix (also with Razor)
    • WebMatrix is a small development environment that uses the simple Razor syntax to create websites really quickly. You can start from a gallery of existing open source applications or start from scratch. For example, Rob Conery and I wrote the little podcast site and feed for in a day with WebMatrix.
    • NuGet package management is built into WebMatrix, too! Make a new site, run it, and hit /_admin. Dance.
  • IIS 7.5 Express
    • Yes, you can install it on its own. It's IIS, except it runs as a user process rather than a service. Cassini (Visual Developer Web Server) is dead! It's "just in time" IIS. There when you need it, and not running when it's not used.
    • This is the web server that Web Matrix uses today, but it'll be enabled in Visual Studio 2010 when SP1 comes out.
  • SQL Compact Edition 4
    • SQL Compact Edition is sweet because is a tiny in-process (no services, don't need to be admin) database that's great for small sites that aren't ready for SQL Server proper. It's xcopy-deployable and runs nicely on hosted sites. It's the default database for WebMatrix and I'm using it in Visual Studio for sites where my database isn't big enough to justify a SQL license.
    • You can use SQL Compact today in Visual Studio at runtime, much like I did in my PDC talk, but you won't be able to design and open your database in VS until SP1. (You can use this Non-MS CodePlex project temporarily, but I didn't tell you.)
  • Web Farm Framework 2.0 and Web Deploy
    • Makes setting up multiple servers way easier. Treat and manage groups of servers, use ARR for load-balancing (or use 3rd party balancers), and upgrade, switch, and add servers with PowerShell. Mmm....PowerShell.
  • Orchard 1.0
    • This free, open-source content management system is ready to go. The release is published on the Orchard CodePlex website and Microsoft Web Application Gallery. You can use Orchard all up, or you can take it apart and just use pieces. Mix and match as you like.

It's the January Web Release, say I, and the easiest way to get it is with Web Platform Installer 3.0, which also went live today. Using direct links to products within the Web Platform installer will automatically add any dependencies you might need.

Now what? I'm freaking out!

Folks sometimes say "slow down, you're freaking me out, this is too much new stuff. What about my current stuff?" Here's a few statements from me personally on today's releases.

  • Just because ASP.NET MVC 3 came out today, doesn't mean WebForms doesn't have some cool features coming. Remember that "ASP.NET > ASP.NET MVC". You'll see features and improvements from both technologies move between MVC and WebForms.
  • IIS Express will integrate with VS2010 in SP1 and work with both WebForms and MVC.
  • You can mix Razor Views and Web Forms Views within MVC. The creation/existence of Razor doesn't obviate your existing work.
  • SQL Compact works great with WebForms as well as ASP.NET MVC, not to mention any .NET project. Ever want a tiny database for a command-line app and didn't want the headache? Bam.
  • SQL Compact database can be upgraded into full SQL Server databases when/if you outgrow SQL Compact.
  • While NuGet is bundled with ASP.NET MVC in today's release, you can use it for any .NET project type. Most NuGet libraries are not specific to ASP.NET MVC.

As I've said before, Microsoft is creating new LEGO pieces for software development to round our existing collection of bricks out. Be exited about these bricks, but remember they augment the existing ones, not replace them.

What now?

I'd recommend you go get MVC3 and WebMatrix, preferably at the same time via one of these Web Platform links. That should get you all these other nice things chained in. In the spring when VS2010 SP1 comes out, the tooling and management bits for SQL Compact and IIS Express will be enabled.

Stuff to Get

ReSharper Updated

One other note, the folks at JetBrains were ready for this and spun a new build of ReSharper, so ReSharper 5.1.2 doesn’t interfere with Visual Studio IntelliSense in ASP.NET MVC 3 Razor syntax. Earlier ReSharper 5.x builds had certain issues with Razor IntelliSense that are addressed in 5.1.2. Specifically, ReSharper 5.1.2 doesn’t prevent Visual Studio from automatically providing its own IntelliSense in .cshtml and .vbhtml web pages anymore: both code completion and Parameter Info work as expected. Other than that, ReSharper 5.x doesn’t provide any additional support for Razor: only ReSharper 6 will bring full support for this view engine. Pre-release ReSharper 6 builds are currently available via Early Access Program, so if you're a ReSharper user, be aware!


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

Integrating ASP.NET MVC 3 into existing upgraded ASP.NET 4 Web Forms applications

January 6, '11 Comments [42] Posted in ASP.NET | ASP.NET MVC | VS2010
Sponsored By

I got an interesting question recently from a gentleman who has an existing ASP.NET WebForms 2.0 application that works just fine. He's upgraded it to ASP.NET 4 and it still works great, but now he wants to add some ASP.NET MVC pages to it. He doesn't want to rewrite the application.

A few years ago I did a post on "Hybrid" ASP.NET applications. The goal was to reinforce the point that you can have ASP.NET applications that are both WebForms and MVC (as well as WCF and ASMX Web Services and on and on.) While the File|New Project dialog gives you a choice between This and That, in fact it's all ASP.NET underneath. You are welcome to mix and match "cafeteria style" and create apps in any combination you'd like.

The easiest way to add ASP.NET MVC 3 to an upgraded ASP.NET 2.0 WebForms application:

  • Run the Upgrade Wizard (open the  Visual Studio2008 Web Application in Visual Studio 2010)
  • Create a default ASP.NET MVC application for reference (you'll throw it away later)
  • Use a differencing tool like Beyond Compare to integrate the new web.config entries from the ASP.NET MVC sections into the upgraded ASP.NET WebForms application
  • Dance

Here's the longer more detailed version of the above.

Upgrading an ASP.NET 2.0 WebForms Application

I've created a simple Visual Studio 2008 ASP.NET WebForms Application running under .NET 2. It's a simple calculator.

WebApplication1 - Microsoft Visual Studio (7)

It works nicely. Now, open this application in Visual Studio 2010. You'll get the Conversion/Upgrade Wizard.

Visual Studio Conversion Wizard (6)

Next, Next, Yada, Yada, Yada, Finish. You'll get an prompt to upgrade the 2.0 application to .NET Framework 4. Click Yes.

Web Site targeting older .Net Framework Found (8)

Here's the same WebForms application, now upgraded in Visual Studio 2010. It still runs and it's still WebForms. Or, more accurately, it continues to  be ASP.NET.

WebApplication1 - Microsoft Visual Studio (9) 

I'm going to take a new default ASP.NET MVC 3 application and Beyond Compare and compare the upgraded app with the default app.

WebApplication1 _--_ MvcApplication1 - Folder Compare - Beyond Compare (10)

I'll copy over these folders and files:

  • Content
  • Controllers
  • Models
  • Scripts
  • Views
  • Global.asax, Global.asax.cs

Now, here's the before and after references from the upgraded application. The old on the left and the new on the right.

New ReferencesReferences

Here's the references I added.

  • Microsoft.CSharp
    • (as this was a C# app)
  • System.Web.Mvc
    • From \Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies
  • System.Web.WebPages and System.Web.Razor
    • From \Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies
  • System.ComponentModel.DataAnnotations

Next, add these sections to the Web.config. Again, it's easier to use a diff tool and you might have a little trial and error.

Thought: This might be a nice NuGet package for someone to make...

Add these settings in appSettings:

<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>

Add these assembly elements under compilation:

<compilation debug="true" targetFramework="4.0">
<add assembly="System.Web.Abstractions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

Add these namespaces in pages:

<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages"/>

If you're running IIS7 at some point, which I'm sure you will, add these:

<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>

And finally add this assembly binding redirect, just in case you've got ASP.NET MVC 1 or 2 assemblies in your Global Assembly Cache (GAC).

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="" newVersion="" />

Also, make sure you merge in the Global.asax.cs so that your Routes are registered at application startup.

public class SomeHybrid: System.Web.HttpApplication
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
filters.Add(new HandleErrorAttribute());

public static void RegisterRoutes(RouteCollection routes)

"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults


protected void Application_Start()


Now, at this point I can visit both pages. The WebForms page is a file on disk, so ASP.NET routing passes requests directly on to this page when I /default.aspx. The ASP.NET Routing engine is engaged so I can also hit /Home/Index.

If I want to get fancy, I can add a PageRoute so I have pretty URLs when visit my WebForms pages as well. Just add a route in the Global.asax like this. Make sure that simple routes like these come first, as the default ASP.NET MVC route is very "greedy" and would gobble up a simple URL like /calculator

routes.MapPageRoute("WebFormThing", "Calculator", "~/Default.aspx");

Now I can visit /Calculator and the request is routed to /Default.aspx. And of course, my ASP.NET MVC 3 Razor pages like /Home/Index work also.

http___localhost_12089_Calculator - Windows Internet Explorer (18)

Finally, just to make the point, here's the Default.aspx from the WebForms part of my new app next to the source for a Razor page.

WebApplication1 - Microsoft Visual Studio (16)

You CAN have it all, Dear Reader. Enjoy.

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 Weekly Source Code 58 - Generating (Database) Test Data with AutoPoco and Entity Framework Code First

January 5, '11 Comments [26] Posted in Open Source | Source Code
Sponsored By

I was messing around with Entity Framework Code First for data access recently (what I like to call EF Magic Unicorn) and had a need to create a bunch of test data. Such a chore. It's totally no fun and I always end up slapping the keyboard thinking that someone else should be slapping the keyboard. Test data for 10 instances of a class is easy, but 1000 is some how less inspiring.

Sure, there's lots of software I could buy to solve a problem like that, but meh. I dug around some and found an open source framework called AutoPoco from Rob Ashton (@robashton). First, awesome name. I like using open source projects with cool names. It's kind of like reading a book with a great cover. Makes you feel good jumping in. Then, I started working with it and realized there's some substance to this modest little library. All the better, right?

AutoPoco's CodePlex project says:

AutoPoco is a highly configurable framework for the purpose of fluently building readable test data from Plain Old CLR Objects

Here's the general idea. You need 100 of something (or 5, or whatever) setup a certain way, so you ask AutoPoco to construct a bunch of you, and it's so. It's that easy.

For example, please get me 1000 objects of type SimpleUser and make their FirstName's all "Bob.":

IList<SimpleUser> users = session.List<SimpleUser>(1000).Impose(x => x.FirstName, "Bob").Get();

Here's where it really shines, though:

.Impose(x => x.FirstName, "Rob")
.Impose(x => x.LastName, "Ashton")
.Impose(x => x.FirstName, "Luke")
.Impose(x => x.LastName, "Smith")
.Impose(x => x.Role,roleOne)
.Impose(x => x.Role,roleTwo)
.Impose(x => x.Role, roleThree)
.Invoke(x => x.SetPassword("Password1"))

This says:

Create 100 users
The first 50 of those users will be called Rob Ashton
The last 50 of those users will be called Luke Smith
25 Random users will have RoleOne
A different 25 random users will have RoleTwo
And the other 50 users will have RoleThree
And set the password on every single user to Password1

Effectively, the sky's the limit. You can also give AutoPoco more advanced requirements like 'make emails meet these requirements," or "call this method when it's time to get a password." The idea being not just to make test data, but to make somewhat meaningful test data.

This got me thinking that since we're using POCOs (Plain Ol' CLR Objects) that I could use this not only for Unit Tests but also Integration Tests and Smoke Tests. I could use this to generate test data in a database. All the better to use this with the new Entity Framework stuff that also uses POCOs.

For example:

public void MakeTestData()
IGenerationSessionFactory factory = AutoPocoContainer.Configure(x =>
x.Conventions(c => { c.UseDefaultConventions(); });

IGenerationSession session = factory.CreateSession();

IList<SimpleUser> users = session.List<SimpleUser>(1000)
.Impose(x => x.FirstName, "Bob")
.Impose(x => x.FirstName, "Alice")
.Impose(x => x.LastName, "Hanselman")
.Impose(x => x.LastName, "Blue")
.Impose(x => x.LastName, "Red")

SimpleUserDatabase db = new SimpleUserDatabase();
foreach (SimpleUser s in users)

And boom, I've got 1000 users in my little database.

I've talked to the author, Rob, and I think that the Session creation and Factory stuff could be made smaller, and the loop at the bottom could be reduced a line or two. Rob's a practical guy, and I look forward to where AutoPoco goes next! All in all, what a useful library. I can see myself using this a lot.

You can get AutoPoco from CodePlex, or even better, from inside Visual Studio using NuGet ( via "install-package autopoco."

Enjoy! This library has 36 downloads, but deserves a few orders of magnitudes more. I'll do my best to showcase more open source libraries that deserve attention (and more importantly, to be used!) going forward. Feel free to email me suggestions of insanely useful libraries.

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

Adding a Netgear N600 Wireless Dual Band Gigabit Router WNDR3700 to an existing FIOS Wireless AP for improved wireless coverage

January 4, '11 Comments [28] Posted in Hardware | Tools
Sponsored By

A few months ago I added a second wireless access point (AP) to my existing network in order to get better wireless coverage. We have a house that's kind of spread out and we were getting really spotty 802.11g around the house. Laptops we getting one or two bars, or worse yet, they were constantly negotiating network speeds and never getting a decent one. The iOS devices (iPhone, iPad, etc) would barely get any signal in certain rooms. It was certainly irritating.

So, I added a second identical AP with the same SSID upstairs so we could move between floors without trouble. However, this AP (some crappy standard one that came with the FIOS service) was/is really inconsistent. While the network architecture is solid, as is the idea behind my "add a second AP" post, the implementation using these 5 year old crappy routers was flaky at best.

Techie Background: I have FIOS optical internet service, and have for the last 3 years. It's upgraded from 15Mbs to 35Mbs recently. The house is Gigabit Ethernet (all CAT6, see the related links below). All the wired devices are running through a Netgear GS724T-300 24-port Gigabit Smart Switch and all of the wireless devices are at least 2.4Ghz 802.11g, and some are 802.11n, with one being 2.4Ghz or 5Ghz.

Since I have a home office, meaning I literally work at home 90% of the time for my living, having flaky wireless is a problem. I decided to start researching a better solution.  I decided to add a new wireless router. I figured that it was insane for one house to have to APs and that surely if a cell phone could work over miles that a freaking wireless network router could cover a single house. I found the solution in the Netgear N600 Gigabit.

Here's the idea:

Network Diagram with additional Wireless Router

However, there are some important notes when adding a new wireless router to an existing system that is already performing these functions

  • Passing out IP addresses via HDCP
  • Acting as a wireless access point with lots of existing clients
  • Has existing static IP leases setup, existing quality of service (QoS) settings

Stated differently, my existing router is nicely and intricately configured for my house. It works fine and I like it fine, except it has crappy wireless. I want to add a new wireless router without disturbing what already works. If it ain't broke, don't fix it.

I picked up a Netgear N600 Wireless Gigabit Router. Note that there are two versions of this, one with a large bright LED on the outside and one without. The one without has 4 Gigabit LAN ports, and that's the better router.

Let me tell you that this router is awesome. I figured I'd be moving from a 3-5 year old crappy router to some better router, sure, but not a totally awesome Swiss Army Knife. Networking has come a long way since 2005 or whenever my stock router was made.

This Netgear is awesome because of these features:

  • Two separate bands for wireless, each with 300Mbs of independent bandwidth. There's 2.4GHz and 5.0GHz frequencies. Nice for copying VMs over wireless. I made a "HANSELMAN" and "HANSELMAN-N" network.
  • Four Gigabit Ethernet points. Not needed for me, but it's nice to have four more Gigabit ports.
  • Eight internal antennas - Seriously, this thing has insane range. I had already added an external antenna to my FIOS router and still had bad range. This little Netgear covers 3500+ square feet and more. I'm thrilled with the range. I don't need two routers anymore. Adding this router totally achieved my goal.

There were a few gotchas. I still need my ISP's router because it's the bridge to the ISP and the Optical Network Terminal (ONT) they installed on the house. It's also totally configured as I like.

Here's the steps I took:

  • Logged into the FIOS ActionTec at and disabled the wireless interface. I confirmed that the "HANSELMAN" network was no longer showing up.
  • Plugged the Netgear directly into my laptop and visited it's default IP of I disabled the new router's DHCP (this is crucial).
    • Important Trick: I temporarily plugged the new Netgear's yellow "external network" directly into the FIOs ActionTec so the Netgear could update its firmware the first time and get the initial setup wizard would stop nagging me. The router expects to be hooked up in this way at least initially, so you need to satisfy its setup.
  • After the Netgear is configured, now unplug the yellow external LAN wire and instead plug into one of the standard four ethernet ports into either your switch (that's what I did, gigabit to gigabit) or directly into your ISP's router. We want the new router to get an IP address from our existing router and route traffic and DHCP requests to the ISP's router. To be clear: Setting up your new router in this way will leave the yellow upstream external network port empty, despite what the documentation says.
  • On the new router, setup the 2.4GHz wireless network with your SSID, and the 5GHz wireless network with something like YOURSSID-N. Here's what I did:
  • View Available Networks Dialog

Now I've got 192.x.x.x addresses being handed out on two wireless networks. My Wireless-N network is getting 300Mbs throughput on my Lenovo, as its Intel Wireless LAN does 5Ghz 802.11n. Also, my iOS devices are using 2.4Ghz 802.11n and are suddenly a LOT snappier on large downloads and email.

Wireless Network Connection Status

I'm absolutely thrilled with the a Netgear N600 Wireless Gigabit Router. It's the top of the line for the house, definitely a "prosumer" router and a really nice upgrade to any existing system if you know a little about setting up your network. Totally recommended.

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

Hanselminutes Podcast 247 - From Agile Consultant to Agile Team Member with John Wilger

January 3, '11 Comments [4] Posted in Agile | Podcast
Sponsored By

imageScott sits down with former agile coach John Wilger to talk about his experience going to work for the company he originally consulted with. What kinds of issues do small teams deal with when moving from traditional software development processes?

Download: MP3 Full Show

NOTE: If you want to download our complete archives as a feed - that's all 247 shows, subscribe to the Complete MP3 Feed here.

Also, please do take a moment and review the show on iTunes.

Subscribe: Subscribe to Hanselminutes or Subscribe to my Podcast in iTunes or Zune

Do also remember the complete archives are always up and they have PDF Transcripts, a little known feature that show up a few weeks after each show.

Telerik is our sponsor for this show.

Building quality software is never easy. It requires skills and imagination. We cannot promise to improve your skills, but when it comes to User Interface and developer tools, we can provide the building blocks to take your application a step closer to your imagination. Explore the leading UI suites for ASP.NET AJAX,MVC,Silverlight,Windows Forms and WPF. Enjoy developer tools like .NET Reporting, ORM, Automated Testing Tools, Agile Project Management Tools, and Content Management Solution. And now you can increase your productivity with JustCode, Telerik’s new productivity tool for code analysis and refactoring. Visit

As I've said before this show comes to you with the audio expertise and stewardship of Carl Franklin. The name comes from Travis Illig, but the goal of the show is simple. Avoid wasting the listener's time. (and make the commute less boring)

Enjoy. Who knows what'll happen in the next show?

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.