Professional ASP.NET MVC 2 Review

What’s up with Ben? All he’s been writing about lately is Ruby, Ruby, Ruby. Doesn’t he work with ASP.NET MVC anymore? Let me assure you that I do – just about every single day and it’s been for quite a while now. Sure, I have been spending time learning Ruby but I’m also constantly developing my primary craft, ASP.NET MVC with C#. So, inspired by yesterday’s virtual MvcConf, I’m going to get back to what I do every day and share a bit about learning ASP.NET MVC with you.

Professional ASP.NET MVC 2 by Scott Hanselman: Book CoverI have told this story before but early in my career, when I wanted to learn a new technology, I’d sit on the floor in the bookstore aisle and work my way through each of the available books on a given subject.  Put in enough time in a bookstore and you can learn just about anything. I used to really enjoy this time but over the years my habits have certainly changed.  Whereas books used to be the only place I could find solutions to my problems, now they may be the very last place I look. Case in point, it wasn’t until I had worked with the ASP.NET MVC 1.0 Framework for more than a year, and I had a few projects and a couple of major deployments under my belt, did I finally read through Steven Sanderson’s Pro ASP.NET MVC Framework. With so many resources at my fingertips (podcasts, screen casts, blogs, stackoverflow, open source projects, I was able to get up to speed with ASP.NET MVC without reading a single book.  So, I didn’t until late into the game.  

This past April, the day after the RTM release became available, I upgraded my primary MVC project to MVC 2.  Now, a few months later, there are a handful of MVC 2 books on the shelves of those said bookstores and I now offer you a review of Professional ASP.NET MVC 2.  You may know that I have given a lot of praise to Sanderson’s first book so why did I choose Professional ASP.NET MVC 2 over the second edition of Sanderson’s book? Well, the NerdDinner chapter (a.k.a the free bits) of Professional ASP.NET MVC 1.0 offered me a really great MVC primer but I never got around to buying the book.  Not only has the guilt weighed on me a bit, it’s also been quite the cliffhanger.  Having now read through the second edition of Professional ASP.NET MVC 2, I now know that everything worked out for Guthrie, Hanselman, Haack, Conery but I’ve been worried.  (Sorry if I just spoiled the ending for you.)  Anything else?  Yes. Full disclosure, a copy of Professional ASP.NET MVC 2 kind of fell in my lap as Jon gave me a copy on my birthday. He didn’t know it was my big day but it was.  And this leads us into the first thing you’ll undoubtedly notice about the book – there is one more author, Jon Galloway, and the four foreheads on the book cover have been replaced by a blurry bobsled.  Welcome change all around, I think.

As you may have guessed, Professional ASP.NET MVC 2 begins with a new and improved NerdDinner walkthrough. With the book’s first release, I coded up the application from scratch as I followed along, step by step, with the tutorial. I even uncovered and fixed a couple of bugs, but don’t tell.  This new NerdDinner tutorial does a fine job of working in a number features which were introduced with MVC 2.  That’s stuff like HTML Encoding Code Blocks, Strongly Typed HTML Helpers, Templated Helpers, and Client-Side Validation.  There are other new features, and we’ll get to those. If you can get through the tutorial and understand what MVC has to offer, congratulations, you now know enough to be dangerous. But should you stop there? Does the NerdDinner sample application provide you everything you need to become a full-fledged MVC developer?  You might think so, but nope, not even close.  Thus, there’s a lot more book to give you the rest of the scoop.  Think of the NerdDinner sample as the appetizer which whets your appetite, leaving you craving for the main course.  Sorry, I couldn’t help myself…

With that, onto the rest of the book review:

Chapter 2 shares the history of the MVC design pattern and runs through other popular MVC web frameworks you may have seen running in the wild. This chapter also brings attention to the “how” and “why” ASP.NET MVC came into existence. Chapter 3 builds on these same points and explores ASP.NET MVC basics like separation of concerns, maintainability and testability and how ASP.NET MVC relates to both WebForms and ASP.NET as a whole.  You might be thinking, “That’s great but is this going to make me a better MVC developer?”  I was tempted to say that these two chapters aren’t required reading unless you are a complete MVC newbie, but the truth is there’s always value in learning about the background of a technology, pattern, language or framework in order to better understand and master it.  And knowing this information will separate those passionate about MVC from those who merely code against MVC.  So, yes, these chapters will make you a better developer.

Chapter 4 digs into routing and sheds light on a number of sophisticated scenarios. If you have a good handle on routing from your work with MVC 1, you will acknowledge the chapter as being well-written but nothing new is going to jump off the page at you.  However, if you are new to  MVC, you need a strong understanding of outgoing and incoming routes, route patterns and how possible gotchas like Overflow Parameters work and this book does a wonderful job explaining these concepts.  And don’t forget that routing is now exposed in the ASP.NET libraries to be used in WebForms too.  You know, just in case MVC isn’t your cup of tea.

Chapter 5 and 6 dive into controllers and views, respectively.  If you’re new to MVC, the authors walk you through everything you’ll need to know about the C and V in MVC.  For those focusing on the MVC 2 bits, there’s a very nice overview of how requests are handled on the server along with an explanation of how to benefit from the new Asynchronous Controller Actions.  You may have picked up a lot about what views have to offer from the NerdDinner tutorial already but you’d be surprised what else you’ll pick up from this detailed chapter.  Again, for those honing in on MVC 2, give special attention to the new Html.Action and Html.RenderAction helper methods.  Final note on views – I commend the authors for including a rundown of the most popular alternative view engines.  Pretty classy.  On aside, since we’re talking about the V and the C, there isn’t a chapter dedicated to the M, models.  The NerdDinner walkthrough may have sufficiently covered this topic, but the topic was otherwise absent.

Chapter 7 is focused on Ajax, partials and jQuery.  This section is somewhat like a cookbook with lots of recipes.  It’s a little different than the rest of the book as it offers more code examples than written explanation of what the AJAX and jQuery libraries bring to the MVC 2 table. Having worked with MVC for a while now, it’s apparent from Day 1 of development that one needs to have their Ajax and Javascript/jQuery hat on if they want to work with effectively with the framework.  Thankfully Chapter 7 offers a surfeit of practical examples.  Be sure to bookmark this section because you’ll be referring back to it when you need a ratings or autocomplete textbox implementation.

Chapter 8 shows us how one can use Filters to add behavior to action methods.  For the MVC neophytes, filters are powerful.  Soak this chapter in.  For the MVC veterans, be on the look out for the RequireHttps action filter which was introduced with MVC 2. 

Chapter 9 speaks to securing our MVC applications.  I agree with the authors – this should be required reading.  This chapter uses case studies, quotes, short stories, humor, scare tactics, anything and everything to get important points across to the reader.  Listen, security is important.  If you’re a WebForms convert, read carefully as MVC doesn’t hold your hand quite as much as the WebForms world does when it comes to securing your application.  And give thanks to the authors for their willingness to talk about security concerns throughout the book as well dedicate an entire chapter to this topic.  This chapter also includes number of additional reading references which might be worth your time.

Chapter 10 and 11 are dedicated to TDD, unit testing and testable design patterns. The book provides a nice introduction into these topics and solid foundation on how to get started with these design/testing techniques.  Professional ASP.NET MVC 2 includes more than 50 pages of TDD/testing instruction.  Truly, one of the greatest benefits of ASP.NET MVC is testability and if you are new to testing, this book will be a wonderful jumping off point for you.

I’m a bad person. I didn’t read Chapter 12, Best of Both Worlds: Web Forms and MVC Together. I skimmed through it but that’s it.  Obviously there’s demand for this information or it wouldn’t be included in the book but mixing WebForms and MVC doesn’t pertain to me right now. Maybe I’m being shortsighted but I’d like to keep these worlds separate for now. If there comes a time and I need to migrate a WebForms app to MVC, I’ll be sure to come back to this chapter.  For now, it remains unread. Sorry.

Remember how the NerdDinner tutorial sample showed off a number of the new ASP.NET MVC 2 features?  Well, it didn’t catch them all.  That’s where Chapter 13 comes in – offering a roll up of everything new to MVC.  You may actually want to read this chapter first just to become acquainted with the new bits.  That way you can be sure to pick up on the callouts elsewhere in the book.  A couple of important notes – you will find details about Areas in Chapter 13 which you won’t find in any other section. Also there’s an important note about breaking changes with JsonResult when upgrading from MVC 1 to 2.  The change is web vulnerability related and don’t say I didn’t warn you.

A few additional notes about the book which I couldn’t find a good place for elsewhere:

  • Comments from the ASP.NET Product Team are inserted throughout the book. These tips and additional info were my favorite part of the book.  It’s kind of like VH1’s “Behind the Music” to me
  • My only real concern with the NerdDinner tutorial is the emphasis placed on the Entity Framework (EF).  When the original tutorial was published, I encouraged everyone on my team to work through the sample application before diving into their first MVC project.  One of my colleagues was so impressed with MVC that they presented what they learned to the rest of the team.  Guess the name of the presentation. It was “An Overview of the .NET MVC Entity Framework.”  Yikes! In the individual’s defense, they had no prior experience with the .NET stack and frankly the Professional ASP.NET MVC book does drive home the concept of building out one’s model with EF.  There is quick mention of other ORMs which can be used with ASP.NET MVC, but guess which path someone new to .NET will follow?  I don’t feel the use of the Entity Framework is inappropriate in the NerdDinner sample, but I do think it is important to stress (yes, a little more) that EF is not part of the MVC framework and maybe even offer hints as to how one might hook in another ORM if they so choose. This said, I suppose I have the same issue with the references to ASP.NET Forms Authentication, ASP.NET Membership and Role Management APIs, not to mention the Visual Studio Unit Test framework.  [Disclaimer: I am using EF4 and the ASP.NET Membership stuff on my primary project and I think they are both the bees knees.]
  • If you are turning to MVC in hopes to never hear or read about WebForms again, you’re kind of out of luck because Professional ASP.NET MVC offers lots of WebForms commentary.  If you are only interested in MVC, this constant reminder of  WebForms might be a little distracting.
  • In the NerdDinner sample, data-type validation was implemented using DataAnnotations.  DataAnnotations are fine, but I would have liked to read more about validating true business rules (e.g. ensuring passwords are strong, validating a shipping date doesn’t fall on a weekend or holiday, or guaranteeing a submitted email address is unique). Managing this type of validation can be complicated and this topic was glossed over entirely.
  • Your Professional ASP.NET MVC 2 purchase comes with two weeks of TekPub access. You may wish to factor this in when your calculating the true purchase price.

As I alluded to earlier, you may be tempted to read through the NerdDinner tutorial and then go off and code up a storm. Don’t do it! The rest of the book has so much to offer – especially to someone brand new to ASP.NET MVC.  Really, soak up what’s provided in all of the chapters.  And as I climb onto my soapbox, please remember that sample applications like NerdDinner demonstrate basic and generalized implementations in order to highlight new features and ensure focus is firmly set on teaching and learning specific information.  If you wish to really understand ASP.NET MVC 2 development, work through the NerdDinner tutorial, read Professional ASP.NET MVC 2 cover to cover, write lots of your own code, read lots of other people’s code, come up with your own ideas and keep learning from the many other resources which are readily available to you.  I recommend Professional ASP.NET MVC 2 – it’ll get you off to a great start.


  1. Paxil EFECTOS SECUNDARIOS DE LOS ANTIDEPRESIVOSEn algunas personas, los antidepresivos pueden causar efectos secundarios que generalmente son leves y temporales (conocidos a veces como efectos adversos). Sinequan 10 mg Comer bien en las horas fijas, sin hacerlo entre horas. Olanzapine 7.5 mg En las ciudades, los ninos con asma mal controlado o alergias cutaneas serian mas propensos a desarrollar alergias alimentarias. Amitriptyline 10 mg Risperdal en Espana Para estos tratamientos se emplean dosis menores, y a menudo producen efectos mas rapidos que otros medicamentos. Nortriptyline Hydrochloride 25 mg Tambien sabemos que disfunciones sexuales debidas a cuadros depresivos o fobicos mejoran a veces con la medicacion correspondiente, de alli que sea necesaria una evaluacion del estado sexual previo al uso de los antidepresivos de cualquiera de las series. Aripiprazole 20 mg Venta Doxepin Este indice se reduce a 50% en caso de que solo uno de los progenitores sea alergico y a 35% cuando ninguno lo es”, senala el Dr.

  2. This would have to be a new blog. Something that you want to read about, but havent found online. This can be religious, fashion-based, etc. Im just getting some ideas for the blog i want to start- Thanks!.

  3. What i do not realize is actually how you’re not actually much more well-liked than you may be now. You’re so intelligent. You realize thus significantly relating to this subject, made me personally consider it from numerous varied angles. Its like men and women aren’t fascinated unless it’s one thing to do with Lady gaga! Your own stuffs outstanding. Always maintain it up!