Pro ASP.NET MVC 2 Framework
ASP.NET, MVC, Pro ASP.NET MVC June 11th, 2010
This week Apress is sending the second edition of my ASP.NET MVC book to the printers. Hopefully this means you can get your hands on physical copies by the end of this month.
The first edition went deep into the details of the MVC Framework, providing both tutorials and reference material. Judging by sales and review scores, it was a success. The second edition:
- … is thoroughly updated for ASP.NET MVC 2. It explains all the new features, including templating, metadata, validation, asynchronous controllers, areas, HTTP method overloading, strongly-typed input helpers, default parameters, etc., and many are demonstrated in the various tutorials.
- … is updated to account for .NET 4 and Visual Studio 2010. Even though .NET 4/C# 4 is the preferred technology throughout the book, all the documentation and code accounts for readers using .NET 3.5 as well.
- … is updated to reflect more recent patterns and best practices. For example, discussions of automated testing apply ideas from Behaviour Driven Development (BDD) where relevant, and tutorials and descriptions now consistently distinguish between view models and domain models.
- … is updated in light of reader feedback from the first edition. Certain explanations and terminology are overhauled, and the tutorials make use of more effective third-party libraries (e.g., Ninject for Dependency Injection).
This blog post is partly intended to build awareness of the new book, and is partly intended to deal with some of the questions I regularly get by email. So, here are some questions that people frequently ask:
Is this a new book, or an update?
It’s an update of the first edition. The following diagram should clarify what proportions of the book are new, dramatically changed, or just refreshed:
Where and exactly when can I get it?
I don’t know the exact date when it will ship; this depends on physical production and distribution schedules that are beyond my knowledge.
- For printed copies, your best bet is to pre-order with Amazon. Hopefully these will ship around the end of June, but I can’t guarantee it.
- For the eBook version, keep checking the Apress web site.
There’ll probably be a Kindle version in due course, too.
If I already have the first edition, should I buy the second edition?
If you use ASP.NET MVC regularly - especially if plan to use the new MVC 2 features but haven’t yet learned about them in depth - you may well get a lot out of reading the new edition and seeing what’s the same and what’s new. You may also have colleagues who need a deeper knowledge of the whole MVC Framework, including both v1 and v2 features.
However if you don’t use ASP.NET MVC much and don’t intend to migrate your development to v2, perhaps there isn’t such a strong case for buying an update of a book you already own.
Some readers have asked if they can get a sort of “upgrade” edition which contains only the new material. That wouldn’t really make sense for this book, as the new concepts and practices are applied throughout. I don’t present “old” material followed by “new” material – the whole manuscript is updated as a single coherent guide to ASP.NET MVC 2 from the beginning as I believe this gives the clearest understanding.
What new and updated in the second edition?
There are far too many updates and enhancements in the new edition to describe them all. Here’s a brief outline of the table of contents and roughly how each chapter has changed.
Chapter 1: What’s the Big Idea?
Updated to account for ASP.NET 4, including improvements to WebForms and how this impacts the comparison between the two frameworks. Gives an overview of what’s new in ASP.NET MVC 2. Changed the discussion general software development practices to account for more recent trends.
Chapter 2: Your First ASP.NET MVC Application
Tutorial now accounts for your choice of Visual Studio 2008 or Visual Studio 2010. Uses new ASP.NET MVC 2 features, including empty project template, automatic HTML encoding, and Data Annotations validation. Streamlined the flow of the tutorial to improve readability.
Chapter 3: Prerequisites
Describes newer architectural patterns including MVVM. Discussion of automated testing expanded to cover integration testing as well as unit testing, and demonstrates Cucumber-style BDD testing and explains the tradeoffs between this and traditional unit TDD. Various updates to terminology and explanations.
Chapter 4, 5, 6: SportsStore tutorial
Now accounts for your choice of Visual Studio 2008 or Visual Studio 2010. Improved the code: better project structure, uses Ninject instead of Castle Windsor for DI, has better unit test naming (BDD-style) with a clearer description of the limitations of such testing. Applies the viewmodel pattern and related terminology more consistently.
Adapted the tutorial to benefit from MVC 2 features including optional parameters, metadata, scaffolding, client-side validation, automatic (de)serialization, etc. Some parts of the tutorial now go in a different order to make it easier to follow.
Chapter 7: Overview of ASP.NET MVC Projects
Updated to account for ASP.NET MVC 2’s two project template options (empty and non-empty), and for changes in the core ASP.NET 4 platform regarding configuration and deployment.
Chapter 8: URLs and Routing
Now covers areas – reasons for using them, setting them up, their impact on routing, how to avoid common problems, how to unit test their routing configuration. Explains how .NET 4 changes where the routing code lives and how ASP.NET MVC 2 deals with controller namespaces. Many smaller changes.
Chapter 9: Controllers
The 1st edition’s “Controllers” chapter is now split in two – this first chapter now covers introductory topics – receiving input data with parameter binding etc, producing output with action results etc., unit testing.
Has many changes to account for ASP.NET MVC 2, such as its enhancements to TempData. Also describes .NET 4 features – using optional parameters (and how these differ from ASP.NET MVC 2’s parameter defaults), using “dynamic” as a model type, etc. Expands the coverage of unit testing, demonstrating 5 ways to make mocking controllers easier.
Chapter 10: Controller Extensibility
The 1st edition’s “Controllers” chapter is now split in two – this second chapter now covers more advanced topics – custom filters, method selectors, controller factories, etc.
Updated to reflect changes in the ASP.NET MVC 2 request-processing pipeline, new built-in filters, HTTP Method Overriding, etc. Adds (a lot of) coverage of asynchronous controllers – not just how to use them, but how to measure their impact and avoid common misconfiguration problems.
Chapter 11: Views
Goes into detail about how automatic HTML encoding works. Coverage of HTML helper methods expanded for ASP.NET MVC 2 (there’s now over 50 helpers, and that’s before you even start counting all their different overloads). Explains new ways to render partials.
Chapter 12: Models
Most of this massive chapter is totally new, and goes into great detail about metadata, templating, and validation. Covers how the built-in templates work, creating custom ones, using HTML field prefixes, implementing custom metadata sources, consuming metadata, custom validation providers, custom client-side validation, doing all this inside a multi-tier architecture, etc.
The explanation of model binding and value providers is significantly updated to account for the new architecture in ASP.NET MVC 2.
Chapter 13: User Interface Techniques
This new chapter inherits UI-related material from various parts of the 1st edition book, including wizards, CAPTCHAs, child actions, master pages, open-source view engines, custom view engines. All updated to match ASP.NET MVC 2, of course.
Chapter 14: Ajax and Client Scripting
Updated various aspects of the code and explanations to account for new framework features, and to make things work with more recent versions of IE. Expanded the coverage of JSON data services, including security issues and ways to handle cross-domain requests. Some recommendations are updated to account for client-side performance considerations(browser’s rendering pipeline, CDNs, etc).
Chapter 15: Security and Vulnerability
Mostly the same as in the first edition. Shows an alternative tamper-proofing mechanism using MVC 2 code, plus describes JavaScript string encoding and its relation to script injection. Various code changes to fit in with ASP.NET MVC 2.
Chapter 16: Deployment
Radically restructured chapter – now all organized with step-by-step guides and checklists for each targeted IIS version, so now you only have to read the material relevant to you. Covers new deployment options, including combinations of .NET 3.5 SP1, .NET 4, Server 2003, Server 2008, Server 2008 R2, Server 2008 R2 Core, shared hosting, classic/integrated pipeline mode, etc. Accounts for many changes to these deployment environments since the 1st edition, including IIS 7.5-specific issues
Clearer explanations of various IIS request-processing mechanisms. A new section describes VS2010’s improved publishing and packaging mechanisms, config file transforms, etc.
Chapter 17: Using ASP.NET Core Platform Features
Mostly the same as in the first edition. Updated to account for ASP.NET MVC 2, IIS 7.5, with tweaks to code and explanations. Information about configuration APIs moved from Deployment chapter into this chapter.
Chapter 18: Migrating Existing Applications to ASP.NET MVC 2.0
Various updates relating to .NET 4 / VS2010 / ASP.NET MVC 2, including how to upgrade Web Forms applications to support MVC, using routing when combining MVC with Web Forms (both on .NET 3.5 and .NET 4), ways you can use Web Forms server controls with postbacks in MVC 2, should you wish to.
New section describes upgrading from ASP.NET MVC 1 – using automated tooling, doing it manually, a post-upgrade checklist, workarounds for potential problems.
OK, enough details
Of course, there are other ASP.NET MVC 2 books in the pipeline too. No doubt you’ll enjoy and benefit from any of them.

June 11th, 2010 at 11:54 am
First edition was fantastic, really looking forward to this!
June 11th, 2010 at 12:01 pm
Well done, a lot of hard effort.
Ordered my copy already
June 11th, 2010 at 12:30 pm
Awesome - will get my copy ordered, first book was great!
June 11th, 2010 at 2:24 pm
Already pre-ordered, based on reviews of the previous edition. Can’t wait for it to arrive!
June 11th, 2010 at 2:56 pm
Thanks for the graph/piechart on what’s old, what’s new, and what’s been updated. I’ve already pre-ordered my copy from Amazon.com and looking forward to it.
Also, wanted to ask about MS’s Unity vs. Ninject and other DI/IoC frameworks.
Do you have any experience w/ Unity? Why did you pick Ninject? (and switch away from Castle Windsor?) Just curious, as I’m still learning about DI.
Thanks!
June 11th, 2010 at 3:15 pm
You know, this is the type of post every author should make. I have the first edition and honestly wasn’t planning on buying the second only because I felt I could get most of what I needed about changes to the MVC framework online. But after reading this I pre-ordered the new book from Amazon right away.
June 11th, 2010 at 5:30 pm
I pre-ordered this book about 3 months ago and appreciate the update! Do you cover best practices in this book for separating out logic (IoC, Routing, etc…) from the Global.asax? This is something I have struggled to find good information on and was hoping to find good solutions in this book.
I am with Mister Matt, why Ninject 2 and not something like Structuremap?
June 11th, 2010 at 5:53 pm
Great stuff, been waiting for this book, and the new EF4 book too
June 12th, 2010 at 12:28 am
I absolutely loved the first edition. I have never come across a book as coherent and well written and focusing on *real* scenarios.
I preordered V2 a month ago and am really looking forward to it arriving.
Thanks for getting me hooked on testing too!
June 12th, 2010 at 11:43 am
Congrats!!!
Will now xVal get a time slice?
June 13th, 2010 at 5:09 pm
Thanks for this post. I wasn’t aware there were going to be so many changes, I’ll definitely be pre-ordering this now. The first edition was one of the best books I ever read.
In regards to the IoC container choice… I use StructureMap myself, but I had no problems substituting Castle Windsor with it in the first book’s example. I went through the SportsStore chapters as normal and then went back and replaced it with StructureMap in a few minutes.
The important thing is that you clearly showed how to use an IoC container in MVC and that made it easy for me to use whichever one I wanted.
June 13th, 2010 at 7:52 pm
As Dan Martin says, first edition was one of the best books on programming topics I ever read, hope I’ll enjoy this version as much! Maybe I’ll actually really understand Model Binding this time round.
See you at CodeGarden in Copenhagen!
June 14th, 2010 at 4:45 am
Been Waiting for this one. Do you have a say to publisher if this can be published in INDIA as well ? They didn’t publish the first version and I had to get it imported through Amazon (takes over a month to arrive!).
I am hoping this book publishes in India else I will have to order through amazon again and patiently wait for over a month
June 14th, 2010 at 7:35 am
[…] Pro ASP.NET MVC 2 Framework - Congratulations to Steve Sanderson, who announces the completion of the Second Edition of his excellent ASP.NET MVC book. The Second edition is fully updated to ASP.NET MVC2 and .NET4 / Visual Studio 2010, and includes a significant amount of new content beyond the first edition. […]
June 14th, 2010 at 9:30 am
Good work, I loved the first book, I’m pre-ordering
June 14th, 2010 at 5:12 pm
Loved the first edition - one of my favorites. Great depth and perspective and very well written. Have had the second edition pre-ordered on Amazon from day 1 - looking forward to it.
June 16th, 2010 at 7:29 pm
Pre-ordered back in March. First edition was the best MVC book out there! I always regretted only getting the eBook. This time around, I’m getting the physical copy. This is THE book to carry around for MVC. Looking forward to it…thanks!
June 18th, 2010 at 8:01 pm
Was this book written — or at least double-checked against — the final release of both .NET 4.0 and the MVC 2.0 specs? Or is it based on a beta version of either?
June 21st, 2010 at 9:33 pm
Can’t wait! In fact, I am getting rather impatient with APress, why can’t they get the PDF out right…this…minute?!
June 22nd, 2010 at 12:42 pm
Can’t wait for the (e)Book, first one was really good! Read the whole thing (don’t usually do that) and have going back to it as a reference.
June 22nd, 2010 at 2:28 pm
Pre-ordered today, looking forward to the read ;).
June 22nd, 2010 at 6:01 pm
Agreed - Ed 1. was the best programming book I’ve read and I’ll be ordering ed 2. I also have the Preview book that APress put out before ed. 1 - the book that made me excited about coding for the web with MS tools again. My Sanderson collection will be complete. Great work, Steve!
June 26th, 2010 at 3:07 pm
Hi there:
just wondering, is the rough cut supposed to be available through Safari? I was looking for it and I couldnt find it
Cheers
Andrea
June 29th, 2010 at 4:23 am
Absolutely loved 1st edition and just purchased 2nd edition ebook from Apress. By the way FLEPSTUDIOLS code gets you 50% off
Looking forward to reading it! Steve, you rock!
I am curious why you decided to switch from Castle to Ninject? I use S#arp Architecture and they did the opposite, switched from Ninject to Castle Windsor.
June 30th, 2010 at 9:57 pm
Have almost finished viewing your excellent series of screencasts on tekpub.com and was moved to buy your MVC 2 book.
I take it there is no way to pre-order this in the UK?? The link provided is to Amazon US….
July 1st, 2010 at 5:31 pm
Great Book!
just bought the ebook. What about the source
?
Tom
July 4th, 2010 at 12:07 pm
Hi, thanks for the great post but your website doesn’t seem to load properly in Safari, any suggestions? Thanks
July 5th, 2010 at 6:10 am
First edition was the best book on MVC (and software development in general). I look forward to this book and any planned future books.
July 5th, 2010 at 5:39 pm
Thanks everyone for your kind comments!
Mister Matt - I went with Ninject just because it’s really easy to set up and demonstrates principles that would apply to any DI container. I switched away from Castle because its tendency towards XML config didn’t turn out to be useful and readers wouldn’t find it as obvious how to install/set up (the biggest cause of errata reports from the 1st edition was people saying they weren’t sure what parts of Castle to install, and the installers changed dramatically after the book was published).
Paul - RE: StructureMap - see above. RE: Global.asax.cs - I haven’t specifically discussed factoring code out of this, but if you wish you can move your routing config (etc) to a separate class and invoke it from Global.asax.cs
Andrei - I’m open to enhancing xVal if there’s a need, but ASP.NET MVC 2 covers most of that functionality now. If there’s anything specific you’d like to add to xVal, please submit a patch
Parag - Sorry, I’ve no idea what Apress plan regarding distribution to India. I would guess they will continue with whatever arrangements they already have in place.
Deathtospam - Yes, the whole things was checked against VS2010 RTM / .NET 4 RTM / ASP.NET MVC 2 RTM.
Aleq - See above for comments about Ninject
Christopher Edwards - You can preorder from amazon.co.uk. It’s in stock now at Amazon US, but Amazon UK lags behind slightly. I’m sure they’ll have it in stock too soon.
Tom Lueers - I’ve submitted the source to Apress so they should put it on their website very soon. If you’re really keen to get it now, please email me and I’ll send it to you directly.
Sina - Really? I’ve just checked it on Safari for Windows and for iPhone and it looked perfect on both. What version of Safari are you using?
July 6th, 2010 at 2:48 am
Steve, the V1 book is the best programming book I have read. Thank you.
Do you use Linq to SQL or Entity Framework 4.0 in the V2 book?
July 7th, 2010 at 1:19 am
It would have been great to see Razor view engine covered in the book
July 7th, 2010 at 12:08 pm
Diane - check the dates
Razor isn’t even available yet and was just announced a day or two ago!
It shouldn’t be a big leap to think in terms of Razor when looking at the default view engine pages.
July 7th, 2010 at 12:12 pm
Just ordered my copy - thanks Steve for your great work on MVC technology
July 7th, 2010 at 1:38 pm
Code download from Apress doesn’t work (corrupt zip file?)… I’m waiting on my book from Amazon and wanted to see the Ninject implementation. Can someone get this fixed??
July 7th, 2010 at 3:41 pm
Kevin, I just checked the code download from Apress.com and it seemed to work fine. Can you email me with details of how it’s not working for you? Thanks.
July 7th, 2010 at 5:24 pm
Pre-ordered 3 copies for my co-workers. They just arrived from Amazon now. Woohoo!
July 13th, 2010 at 9:26 am
I owe my job to the v1 book. I landed my current role after being one of the only dev’s in the area that could do MVC. I’ve just received V2 and I’m impressed with the new content some of it’s old hat but I like the new approach to viewmodels and using the ninject lib for IoC. Steve has a great way of making complex topics simple. looking forward to working my way through the book again.
Thank you so much for this book Steve keep up the good work.
One question why nothing on mvccontrib (only up to the sports store) but not seen anything on that yet. It saves me a lot of time when doing work especially the test helpers.. Would have been nice to see some stuff with it..
July 19th, 2010 at 5:43 am
I’ve enjoyed your postings on variable-length lists in MVC. I may try Knockout next. I saw the review of your book from Scott G. I already knew you were legit after the many articles I’ve read on your site, but that review nudged me to get your book. Thanks for all the advice… it’s helped me a ton!
July 20th, 2010 at 7:16 pm
Dear Steven,
I’ve just purchased your book “Pro ASP.NET MVC 2 Framework” and I’ve read about 200 pages. Thank you a lot for the book Steven it’s one of the best technical books I’ve read in last 5 years. Without trying to create some stupid “books only apps” you create really close to production solutions in a way that is easy to follow and understand.
I hope that you will write some books one other topics also especially about testing because I have a feeling that half of a chapter about testing in this book is not really enough for you to express all your thinking on the topic
Looking forward for your next books.
July 21st, 2010 at 12:15 pm
Dear Steven,
I have your MVC 1 book and just order MVC 2 book. One thing I wonder is in sportstore application you use custome model binding to create the Cart and store it in session object, is there anywhere you remove it from the session object again?
By the way thank you very much, grat book, can’t way for the second to arrive.
July 21st, 2010 at 8:48 pm
The MVC1 book was great, if it was an 8.5 the new MVC2 version is at least a 9.75. Way to go Steve.
I was curious about the switch from Castle Windsor to Ninject, glad to see the answer to that above.
Not sure if it was to simplify things for the book, but I thought it was better to keep the Action methods lean by placing more of the code with LINQ into the model?
It would be nice to see a related blog post focusing on architecture and the model in MVC from a real world project/approach.
Now I have to get back to the book.
July 29th, 2010 at 11:20 am
Dear sir, i really like this book very much. “Pro ASP.NET MVC 2 Framework”. I feel adventure in reading this book, it dont makes your bore at all. but may i know when the 3rd edition will come as MS has released MVC 3.
July 30th, 2010 at 4:48 pm
Hi Faisal
It’s very early days for ASP.NET MVC 3 right now - they’ve just provided the first public preview, but this is a long way from a final release. Anyone developing a production ASP.NET MVC application is likely to stick with ASP.NET MVC 2 for a long time yet! I don’t yet have any plans for if or when I’d write about MVC v3
August 10th, 2010 at 8:49 am
Just to ditto a lot of the other comments - had the 1st edition - fantastic - really got me into the whole MVC/IoC stuff. The 2nd edition arrived recently and can’t wait for read about some of the newer stuff in your concise easy to understand style even though have been using MVC2 on my current project since I started on it.
August 12th, 2010 at 3:32 am
Steve,
I have access to just Visual Web Developer 2010 EXPRESS — will that be sufficient to work through the book’s samples, tutorial, etc.? Is there anything presented in the book that I will NOT be able to experiment with in VWD2010 Express?
Thanks!
August 16th, 2010 at 11:50 am
Hi Steve,
This is really a fantastic book, congratulations.
As I’m reading it I’m trying to develop the SportsStore app and I hvae a problem.
On page 110 (Creating a custom controller factory) you wrote:
private IKernel kernel = new StandardKernel(new SportsStoreServices());
but there is not such a class SportsStoreServices, I’ve read the chapter several times and I can’t find any reference to this.
Something I’ve missed? Please help.
Thanks.
August 18th, 2010 at 6:03 pm
Fernando,
The SportsStoreServices is a private class inside the NinjectControllerFactory, if you didn’t find this out by yourself!
August 19th, 2010 at 7:29 am
Thank you MetaSam, the truth is that I didn’t find out by myself…
I don’t know how many times I read this chapter without noticing this.
Thank’s a lot.
–
Fernando
August 23rd, 2010 at 8:09 am
Cindy - as I understand, you can develop ASP.NET MVC 2 applications using VWD 2010. However, I’ve found that so few developers try to do this that it wasn’t worth the cost to produce a full set of VWD instructions for all the tutorials. I hope you’ll be successful using VWD but I don’t know exactly how it might differ from Visual Studio or how you’ll need to adapt the tutorials in the book.
Fernando - sorry for the slow response.
MetaSam - thanks for answering!
August 30th, 2010 at 5:02 am
Thanks Steve for a wonderful book. The chapter 3 (Prerequisites) is fantastic.