This article also appears in Canadian Developer Connection.
As a rule, Chapter One of most programming books seems to leave me with a vague, unsatisfied feeling. I usually finish them with either:
- A “Hello World”-style application that provides an initial “It compiled!” rush, but little else, or
- A “Trees dies for this?” sort of indignation, if the chapter is one of those perfunctory one with a name like “Getting Started” that provides the same information you gathered while deciding whether to buy the book.
Based on these experiences, I think I can be excused for being a bit skeptical when I read the announcement that Chapter One of Professional ASP.NET MVC 1.0, published by Wrox, was being made available for free download. Of course they’re giving it away for free, I thought, it’s the chapter that’s worth nothing!
A quick aside: If you haven’t heard of ASP.NET MVC, it’s Microsoft’s answer to the MVC-based frameworks that are all the rage these days, such as Ruby on Rails and Django. It’s not a replacement for ASP.NET, but an alternative; if you want to build applications following the REST paradigm, with fine-grained control over the flow of your application and HTML and want to do things “the web way” as opposed to a more “desktop app” way, you should seriously consider trying it out. (For more detailed pros-and-cons considerations of ASP.NET versus ASP.NET MVC, see this article in Nick Berardi’s Code Journal.)
Luckily, curiosity got the better of me and I downloaded the chapter. I got my first sign that wasn’t your garden-variety Chapter One when I looked at the file size and page count. 14 megabytes? 196 pages? Something strange was going on here. Perhaps a glitch during the download?
Once I scrolled past the cover page, the standard Wrox cover featuring the authors and their impressively receding hairlines (hence the nickname for the book, “The Gang of Foreheads”), I hit the introductory paragraph:
The best way to learn a new framework is to build something with it. This first chapter walks through how to build a small, but complete, application using ASP.NET MVC, and introduces some of the core concepts behind it.
That’s right: rather than provide some long-winded perfunctory history of the Model-View-Controller framework, the backstory of how the ASP.NET MVC framework came to be or some simple “Hello World”-style example app of little consequence and requiring less effort, the authors decided to get right down to business and show you how to build an ASP.NET MVC web app. This was a surprise – but a very welcome one!
The application that you build is called “NerdDinner”, a site that lets techies declare Meetup.com-style gatherings and RSVP for them (you can see the finished product in action at NerdDinner.com). You start at ground zero, “File –> New…”, and from there, you build the app with just enough asides to explain a few vital concepts and very few of those false detours that some tutorials lead you down. NerdDinner may be a simple app, but it covers a lot of ground:
- From the basics of CRUD application design in an MVC web framework
- to matters of input validation,
- to registering, authenticating and authorizing users
- to integrating Ajax-enabled forms and an Ajax map
- to the built-in unit testing features of ASP.NET MVC.
By the end of the chapter, you’ve got a nice little application that lies in the “sweet spot”. It’s small enough for you to be able to learn from quickly, yet big enough to show you the ropes behind building the important parts of a CRUD web application that’s ready for public consumption.
I’ve tried out a number of ASP.NET MVC tutorials, and this one’s my hands-down favourite. It’s written by the people behind ASP.NET MVC, it covers a lot of ground, the finished app is an excellent basis for your future projects, there’s a working version online that you can use as a guide and the code works! Even better, this single chapter that packs all this value is free-as-in-beer. I’m sure I’ve paid for whole books that have imparted less knowledge than this single free chapter.
If you’re interested in learning about ASP.NET MVC, download Chapter 1 of Professional ASP.NET MVC 1.0 [13.8 MB PDF] and give it a try. It’s the fastest way to get both a working ASP.NET application and up to speed on Microsoft’s new web application framework. And be sure to tell me how it worked out — if you have any questions or comments, or run into any difficulty with the chapter, let me know – drop me a line via email, send me a tweet or give me a shout-out in the comments.