You are previewing Pro ASP.NET MVC 4, Fourth Edition.
O'Reilly logo
Pro ASP.NET MVC 4, Fourth Edition

Book Description

The ASP.NET MVC 4 Framework is the latest evolution of Microsoft's ASP.NET web platform. It provides a high-productivity programming model that promotes cleaner code architecture, test-driven development, and powerful extensibility, combined with all the benefits of ASP.NET.

ASP.NET MVC 4 contains a number of significant advances over previous versions. New mobile and desktop templates (employing adaptive rendering) are included together with support for jQuery Mobile for the first time. New display modes allow your application to select views based on the browser that's making the request while Code Generation Recipes for Visual Studio help you auto-generate project-specific code for a wide variety of situtations including NuGet support.

In this fourth edition, the core model-view-controller (MVC) architectural concepts are not simply explained or discussed in isolation, but are demonstrated in action. You'll work through an extended tutorial to create a working e-commerce web application that combines ASP.NET MVC with the latest C# language features and unit-testing best practices. By gaining this invaluable, practical experience, you'll discover MVC's strengths and weaknesses for yourself—and put your best-learned theory into practice.

The book's authors, Steve Sanderson and Adam Freeman, have both watched the growth of ASP.NET MVC since its first release. Steve is a well-known blogger on the MVC Framework and a member of the Microsoft Web Platform and Tools team. Adam started designing and building web applications 15 years ago and has been responsible for some of the world's largest and most ambitious projects. You can be sure you are in safe hands.

What you'll learn

  • Gain a solid architectural understanding of ASP.NET MVC 4, including basic MVC

  • Explore the entire ASP.NET MVC Framework

  • Learn what's new in version 4 and how how best to apply these new features

  • See how MVC and test-driven development work in action

  • Capitalize on your existing knowledge quickly and easily through comparison of features in classic ASP.NET to those in ASP.NET MVC

Who this book is for

This book is for web developers with a basic knowledge of ASP.NET and C# who want (or need) to start using the new ASP.NET MVC 4 Framework.

Table of Contents

  1. Titlepage
  2. Dedication
  3. Contents at a Glance
  4. Contents
  5. About the Author
  6. About the Technical Reviewer
  7. Acknowledgments
  8. Part 1: Introducing ASP.NET MVC 4
    1. Chapter 1: What’s the Big Idea?
      1. A Brief History of Web Development
      2. Web Development Today
      3. Key Benefits of ASP.NET MVC
      4. Who Should Use ASP.NET MVC?
      5. What’s New in ASP.NET MVC 4?
      6. Summary
    2. Chapter 2: Your First MVC Application
      1. Preparing the Workstation
      2. Creating a New ASP.NET MVC Project
      3. Rendering Web Pages
      4. Creating a Simple Data-Entry Application
      5. Summary
    3. Chapter 3: The MVC Pattern
      1. The History of MVC
      2. Understanding the MVC Pattern
      3. Applying Domain-Driven Development
      4. Building Loosely Coupled Components
      5. Getting Started with Automated Testing
      6. Summary
    4. Chapter 4: Essential Language Features
      1. Creating the Example Project
      2. Using Automatically Implemented Properties
      3. Using Object and Collection Initializers
      4. Using Extension Methods
      5. Using Lambda Expressions
      6. Using Automatic Type Inference
      7. Using Anonymous Types
      8. Performing Language Integrated Queries
      9. Using Async Methods
      10. Summary
    5. Chapter 5: Working with Razor
      1. Creating the Example Project
      2. Working with the Model Object
      3. Working with Layouts
      4. Using Razor Expressions
      5. Summary
    6. Chapter 6: Essential Tools for MVC
      1. Creating the Example Project
      2. Using Ninject
      3. Unit Testing with Visual Studio
      4. Using Moq
      5. Summary
    7. Chapter 7: SportsStore—A Real Application
      1. Getting Started
      2. Starting the Domain Model
      3. Displaying a List of Products
      4. Preparing a Database
      5. Adding Pagination
      6. Styling the Content
      7. Summary
    8. Chapter 8: SportsStore: Navigation
      1. Adding Navigation Controls
      2. Building the Shopping Cart
      3. Summary
    9. Chapter 9: SportsStore: Completing the Cart
      1. Using Model Binding
      2. Completing the Cart
      3. Submitting Orders
      4. Summary
    10. Chapter 10: SportsStore: Administration
      1. Adding Catalog Management
      2. Summary
    11. Chapter 11: SportsStore: Security & Finishing Touches
      1. Securing the Administration Controller
      2. Image Uploads
      3. Summary
  9. Part 2: ASP.NET MVC 4 in Detail
    1. Chapter 12: Overview of MVC Projects
      1. Working with Visual Studio MVC Projects
      2. Debugging MVC Applications
      3. Summary
    2. Chapter 13: URL Routing
      1. Creating the Example Project
      2. Introducing URL Patterns
      3. Creating and Registering a Simple Route
      4. Defining Default Values
      5. Using Static URL Segments
      6. Defining Custom Segment Variables
      7. Constraining Routes
      8. Routing Requests for Disk Files
      9. Bypassing the Routing System
      10. Summary
    3. Chapter 14: Advanced Routing Features
      1. Preparing the Example Project
      2. Generating Outgoing URLs in Views
      3. Customizing the Routing System
      4. Working with Areas
      5. URL Schema Best Practices
      6. Summary
    4. Chapter 15: Controllers and Actions
      1. Introducing the Controller
      2. Receiving Input
      3. Producing Output
      4. Summary
    5. Chapter 16: Filters
      1. Using Filters
      2. Creating the Example Project
      3. Using Authorization Filters
      4. Using Exception Filters
      5. Using Action Filters
      6. Using Result Filters
      7. Using Other Filter Features
      8. Using the Built-in Filters
      9. Summary
    6. Chapter 17: Controller Extensibility
      1. Creating the Example Project
      2. Creating a Custom Controller Factory
      3. Working with the Built-In Controller Factory
      4. Creating a Custom Action Invoker
      5. Using the Built-In Action Invoker
      6. Improving Performance with Specialized Controllers
      7. Summary
    7. Chapter 18: Views
      1. Creating a Custom View Engine
      2. Working with the Razor Engine
      3. Adding Dynamic Content to a Razor View
      4. Summary
    8. Chapter 19: Helper Methods
      1. Creating the Example Project
      2. Creating Custom Helper Methods
      3. Using the Built-In Form Helper Methods
      4. Summary
    9. Chapter 20: Templated Helper Methods
      1. Reviewing the Example Project
      2. Using Templated Helper Methods
      3. Using Model Metadata
      4. Customizing the Templated View Helper System
      5. Summary
    10. Chapter 21: URL and Ajax Helper Methods
      1. Reviewing and Preparing the Example Project
      2. Creating Basic Links and URLs
      3. Using MVC Unobtrusive Ajax
      4. Creating an Unobtrusive Ajax Form
      5. Setting Ajax Options
      6. Creating Ajax Links
      7. Working with Ajax Callbacks
      8. Working with JSON
      9. Summary
    11. Chapter 22: Model Binding
      1. Preparing the Example Project
      2. Understanding Model Binding
      3. Using the Default Model Binder
      4. Manually Invoking Model Binding
      5. Customizing the Model Binding System
      6. Summary
    12. Chapter 23: Model Validation
      1. Creating the Example Project
      2. Explicitly Validating a Model
      3. Displaying Validation Messages
      4. Using Alternative Validation Techniques
      5. Performing Client-Side Validation
      6. Performing Remote Validation
      7. Summary
    13. Chapter 24: Bundles and Display Modes
      1. Understanding the Default Script Libraries
      2. Preparing the Example Application
      3. Managing Scripts and Style Sheets
      4. Using Script and Style Bundles
      5. Targeting Mobile Devices
      6. Summary
    14. Chapter 25: Web API
      1. Understanding the Web API
      2. Creating the Web API Application
      3. Creating the API Controller
      4. Understanding How the API Controller Works
      5. Writing the JavaScript Code to Use the Web API
      6. Summary
    15. Chapter 26: Deployment
      1. Preparing an Application for Deployment
      2. Preparing Windows Azure
      3. Deploying the Application
      4. Summary
  10. Index