Book description
Author Steven Sanderson has seen the ASP.NET MVC Framework mature from the start, so his experience, combined with comprehensive coverage of all the new features, including those in the official MVC development toolkit, offers the clearest understanding of how this exciting new framework can improve your coding efficiency. With this book, you'll gain invaluable up-to-date knowledge of security, deployment, and interoperability challenges.
The ASP.NET MVC 2 Framework is the latest evolution of Microsoft's ASP.NET web platform. It introduces a radically new high-productivity programming model that promotes cleaner code architecture, test-driven development, and powerful extensibility, combined with all the benefits of ASP.NET 3.5.
In this book, 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.
Table of contents
- Copyright
- About the Author
- About the Technical Reviewer
- Acknowledgments
- Introduction
-
I. Introducing ASP.NET MVC 2
- 1. What's the Big Idea?
-
2. Your First ASP.NET MVC Application
- 2.1. Preparing Your Workstation
- 2.2. Creating a New ASP.NET MVC Project
- 2.3. Rendering Web Pages
- 2.4. A Starter Application
- 2.5. Summary
-
3. Prerequisites
- 3.1. Understanding MVC Architecture
- 3.2. Domain Modeling
- 3.3. Building Loosely Coupled Components
- 3.4. Getting Started with Automated Testing
-
3.5. C# 3 Language Features
- 3.5.1. The Design Goal: Language-Integrated Query
- 3.5.2. Extension Methods
- 3.5.3. Lambda Methods
- 3.5.4. Generic Type Inference
- 3.5.5. Automatic Properties
- 3.5.6. Object and Collection Initializers
- 3.5.7. Type Inference
- 3.5.8. Anonymous Types
- 3.5.9. Using LINQ to Objects
- 3.5.10. Lambda Expressions
- 3.5.11. IQueryable<T> and LINQ to SQL
- 3.6. Summary
- 4. SportsStore: A Real Application
-
5. SportsStore: Navigation and Shopping Cart
- 5.1. Adding Navigation Controls
- 5.2. Building the Shopping Cart
- 5.3. Submitting Orders
- 5.4. Summary
-
6. SportsStore: Administration and Final Enhancements
- 6.1. Adding Catalog Management
- 6.2. Securing the Administration Features
- 6.3. Image Uploads
- 6.4. Summary
-
II. ASP.NET MVC in Detail
-
7. Overview of ASP.NET MVC Projects
- 7.1. Developing MVC Applications in Visual Studio
- 7.2. The Request Processing Pipeline
- 7.3. Summary
-
8. URLs and Routing
- 8.1. Putting the Programmer Back in Control
-
8.2. Setting Up Routes
- 8.2.1. Understanding the Routing Mechanism
- 8.2.2. Adding a Route Entry
- 8.2.3. Using Parameters
- 8.2.4. Using Defaults
- 8.2.5. Using Constraints
- 8.2.6. Prioritizing Controllers by Namespace
- 8.2.7. Accepting a Variable-Length List of Parameters
- 8.2.8. Matching Files on the Server's Hard Disk
- 8.2.9. Using IgnoreRoute to Bypass the Routing System
-
8.3. Generating Outgoing URLs
- 8.3.1. Generating Hyperlinks with Html.ActionLink()
- 8.3.2. Generating Links and URLs from Pure Routing Data
- 8.3.3. Performing Redirections to Generated URLs
- 8.3.4. Understanding the Outbound URL-Matching Algorithm
- 8.3.5. Generating Hyperlinks with Html.ActionLink<T> and Lambda Expressions
- 8.3.6. Working with Named Routes
- 8.4. Working with Areas
- 8.5. Unit Testing Your Routes
- 8.6. Further Customization
- 8.7. URL Schema Best Practices
- 8.8. Summary
-
9. Controllers and Actions
- 9.1. An Overview
- 9.2. Receiving Input
-
9.3. Producing Output
- 9.3.1. Understanding the ActionResult Concept
- 9.3.2. Returning HTML by Rendering a View
- 9.3.3. Performing Redirections
- 9.3.4. Returning Textual Data
- 9.3.5. Returning JSON Data
- 9.3.6. Returning JavaScript Commands
- 9.3.7. Returning Files and Binary Data
- 9.3.8. Creating a Custom Action Result Type
-
9.4. Unit Testing Controllers and Actions
- 9.4.1. How to Arrange, Act, and Assert
- 9.4.2. Testing a Choice of View and ViewData
- 9.4.3. Testing Redirections
- 9.4.4. More Comments About Unit Testing
- 9.4.5. Mocking Context Objects
-
9.4.6. Reducing the Pain of Mocking
- 9.4.6.1. Method 1: Make a Reusable Helper That Sets Up a Standard Mock Context
- 9.4.6.2. Method 2: Access Dependencies Through Virtual Properties
- 9.4.6.3. Method 3: Receive Dependencies Using Model Binding
- 9.4.6.4. Method 4: Turn Your Dependencies into DI Components
- 9.4.6.5. Method 5: Factor Out Complexity and Don't Unit Test Controllers
- 9.5. Summary
-
10. Controller Extensibility
-
10.1. Using Filters to Attach Reusable Behaviors
- 10.1.1. Introducing the Four Basic Types of Filter
- 10.1.2. Applying Filters to Controllers and Action Methods
- 10.1.3. Creating Action Filters and Result Filters
- 10.1.4. Creating and Using Authorization Filters
- 10.1.5. Creating and Using Exception Filters
- 10.1.6. Bubbling Exceptions Through Action and Result Filters
- 10.1.7. The [OutputCache] Action Filter
- 10.1.8. The [RequireHttps] Filter
- 10.1.9. Other Built-In Filter Types
-
10.2. Controllers As Part of the Request Processing Pipeline
- 10.2.1. Working with DefaultControllerFactory
- 10.2.2. Creating a Custom Controller Factory
- 10.2.3. Customizing How Action Methods Are Selected and Invoked
- 10.2.4. Overriding HTTP Methods to Support REST Web Services
-
10.3. Boosting Server Capacity with Asynchronous Controllers
- 10.3.1. Introducing Asynchronous Requests
-
10.3.2. Using Asynchronous Controllers
- 10.3.2.1. Turning a Synchronous Action into an Asynchronous Action
- 10.3.2.2. Passing Parameters to the Completion Method
- 10.3.2.3. Controlling and Handling Timeouts
- 10.3.2.4. Using Finish() to Abort All Remaining Asynchronous Operations
- 10.3.2.5. Using Sync() to Transition Back to the Original HTTP Context
- 10.3.3. Adding Asynchronous Methods to Domain Classes
- 10.3.4. Choosing When to Use Asynchronous Controllers
- 10.4. Summary
-
10.1. Using Filters to Attach Reusable Behaviors
-
11. Views
- 11.1. How Views Fit into ASP.NET MVC
- 11.2. Web Forms View Engine Basics
- 11.3. Using Inline Code
- 11.4. Understanding How MVC Views Actually Work
-
11.5. Using HTML Helper Methods
- 11.5.1. The Framework's Built-In Helper Methods
- 11.5.2. Creating Your Own HTML Helper Methods
- 11.6. Using Partial Views
- 11.7. Summary
-
12. Models and Data Entry
- 12.1. How It All Fits Together
-
12.2. Templated View Helpers
- 12.2.1. Displaying and Editing Models Using Templated View Helpers
- 12.2.2. Using Partial Views to Define Custom Templates
- 12.3. Model Metadata
-
12.4. Model Binding
- 12.4.1. Model-Binding to Action Method Parameters
- 12.4.2. Model-Binding to Custom Types
- 12.4.3. Invoking Model Binding Directly
- 12.4.4. Model-Binding to Arrays, Collections, and Dictionaries
- 12.4.5. Creating a Custom Value Provider
- 12.4.6. Creating a Custom Model Binder
- 12.4.7. Using Model Binding to Receive File Uploads
-
12.5. Validation
- 12.5.1. Registering and Displaying Validation Errors
- 12.5.2. Performing Validation As Part of Model Binding
- 12.5.3. Specifying Validation Rules
- 12.5.4. Invoking Validation Manually
- 12.5.5. Using Client-Side Validation
- 12.5.6. Putting Your Model Layer in Charge of Validation
- 12.6. Summary
-
13. User Interface Techniques
- 13.1. Wizards and Multistep Forms
- 13.2. Implementing a CAPTCHA
-
13.3. Using Child Actions to Create Reusable Widgets with Application Logic
- 13.3.1. How the Html.RenderAction Helper Invokes Child Actions
- 13.3.2. When It's Appropriate to Use Child Actions
- 13.3.3. Creating a Widget Based on a Child Action
- 13.3.4. Capturing a Child Action's Output As a String
- 13.3.5. Detecting Whether You're Inside a Child Request
- 13.3.6. Restricting an Action to Handle Child Requests Only
- 13.4. Sharing Page Layouts Using Master Pages
- 13.5. Implementing a Custom View Engine
- 13.6. Using Alternative View Engines
- 13.7. Summary
-
14. Ajax and Client Scripting
- 14.1. Why You Should Use a JavaScript Toolkit
- 14.2. ASP.NET MVC's Ajax Helpers
-
14.3. Using jQuery with ASP.NET MVC
- 14.3.1. Referencing jQuery
- 14.3.2. Basic jQuery Theory
- 14.3.3. Adding Client-Side Interactivity to an MVC View
- 14.3.4. Ajax-Enabling Links and Forms
- 14.3.5. Client/Server Data Transfer with JSON
- 14.3.6. Performing Cross-Domain JSON Requests Using JSONP
- 14.3.7. Fetching XML Data Using jQuery
- 14.3.8. Animations and Other Graphical Effects
- 14.3.9. jQuery UI's Prebuilt UI Widgets
- 14.3.10. Summarizing jQuery
- 14.4. Summary
-
7. Overview of ASP.NET MVC Projects
-
III. Delivering Successful ASP.NET MVC 2 Projects
-
15. Security and Vulnerability
- 15.1. All Input Can Be Forged
- 15.2. Cross-Site Scripting and HTML Injection
- 15.3. Session Hijacking
- 15.4. Cross-Site Request Forgery
- 15.5. SQL Injection
- 15.6. Using the MVC Framework Securely
- 15.7. Summary
-
16. Deployment
- 16.1. Server Requirements
- 16.2. Building Your Application for Production Use
- 16.3. IIS Basics
-
16.4. Deploying Your Application
- 16.4.1. Manually Copying Application Files to the Server
- 16.4.2. Bin-Deploying ASP.NET MVC 2
- 16.4.3. Deploying to IIS 6 on Windows Server 2003
-
16.4.4. Deploying to IIS 7.x on Windows Server 2008/2008 R2
- 16.4.4.1. Installing IIS 7.x on Windows Server 2008/2008 R2
- 16.4.4.2. Adding and Configuring a New MVC Web Site in IIS 7.x
- 16.4.4.3. How IIS 7.x Processes Requests in Classic Pipeline Mode
- 16.4.4.4. How IIS 7.x Processes Requests in Integrated Pipeline Mode
- 16.4.4.5. Further IIS 7.x Deployment Considerations
- 16.4.4.6. Troubleshooting IIS 7.x Errors
- 16.4.5. Deploying to IIS 7.5 on Windows Server 2008 R2 Core
- 16.5. Automating Deployments with WebDeploy and Visual Studio 2010
- 16.6. Summary
-
17. ASP.NET Platform Features
- 17.1. Windows Authentication
- 17.2. Forms Authentication
-
17.3. Membership, Roles, and Profiles
- 17.3.1. Setting Up a Membership Provider
- 17.3.2. Using a Membership Provider with Forms Authentication
- 17.3.3. Creating a Custom Membership Provider
- 17.3.4. Setting Up and Using Roles
- 17.3.5. Setting Up and Using Profiles
- 17.4. URL-Based Authorization
- 17.5. Configuration
- 17.6. Data Caching
- 17.7. Site Maps
- 17.8. Internationalization
- 17.9. Performance
- 17.10. Summary
- 18. Upgrading and Combining ASP.NET Technologies
-
15. Security and Vulnerability
Product information
- Title: Pro ASP.NET MVC 2 Framework
- Author(s):
- Release date: July 2010
- Publisher(s): Apress
- ISBN: 9781430228868
You might also like
book
Pro ASP.NET MVC 3 Framework, Third Edition
The ASP.NET MVC 3 Framework is the latest evolution of Microsoft's ASP.NET web platform. It provides …
book
ASP.NET MVC Framework Unleashed
In this book, world-renowned ASP.NET expert and member of the Microsoft ASP.NET team Stephen Walther shows …
book
Pro ASP.NET Core MVC 2
Now in its 7th edition, the best selling book on MVC is updated for ASP.NET Core …
book
Professional ASP.NET MVC 5
ASP.NET MVC insiders cover the latest updates to the technology in this popular Wrox reference MVC …