ffirs.indd ii
9/11/2012 3:00:11 PM
PROFESSIONAL ASP.NET MVC 4
FOREWORD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxvii
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
CHAPTER 1
Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
CHAPTER 2
Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
CHAPTER 3
Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
CHAPTER 4
Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71
CHAPTER 5
Forms and HTML Helpers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
CHAPTER 6
Data Annotations and Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
CHAPTER 7
Membership, Authorization, and Security . . . . . . . . . . . . . . . . . . . . . . . . .137
CHAPTER 8
Ajax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
CHAPTER 9
Routing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
CHAPTER 10
NuGet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
CHAPTER 11
ASP.NET Web API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
CHAPTER 12
Dependency Injection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
CHAPTER 13
Unit Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
CHAPTER 14
Extending MVC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
CHAPTER 15
Advanced Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
CHAPTER 16
Real-World ASP.NET MVC: Building the NuGet.org Website . . . . . . . . 423
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
ffirs.indd i
9/11/2012 3:00:11 PM
ffirs.indd ii
9/11/2012 3:00:11 PM
PROFESSIONAL
ASP.NET MVC 4
ffirs.indd iii
9/11/2012 3:00:11 PM
Try Safari Books Online FREE
for 15 days + 15% off
for up to 12 Months*
Read this book for free online—along with thousands of others—
with this 15
d trial offer.
15-day
With Safari Books Online, you can experience
searchable, unlimited access to thousands of
technology, digital media and professional
development books and videos from dozens of
leading publishers. With one low monthly or yearly
subscription price, you get:
• Access to hundreds of expert-led instructional
videos on today’s hottest topics.
• Sample code to help accelerate a wide variety
of software projects
• Robust organizing features including favorites,
highlights, tags, notes, mash-ups and more
• Mobile access using any device with a browser
• Rough Cuts pre-published manuscripts
START YOUR FREE TRIAL TODAY!
Visit www.safaribooksonline.com/wrox59 to get started.
*Available to new subscribers only. Discount applies to the
Safari Library and is valid for first 12 consecutive monthly
billing cycles. Safari Library is not available in all countries.
badvert_color.indd 1
9/13/2012 2:58:47 PM