Table of Contents – ASP.NET MVC 2 in Action

Table of Contents

Copyright

Brief Table of Contents

Table of Contents

Praise for the First Edition

More Praise for the First Edtion

Foreword

Foreword to the First Edition

Preface

Preface to the First Edition

Acknowledgments

About this Book

About the Authors

About the Cover Illustration

1. High-speed fundamentals

Chapter 1. High-speed beginner ramp-up

1.1. Welcome to ASP.NET MVC

1.2. The MVC pattern

1.3. Creating your first ASP.NET MVC 2 project

1.4. Creating controllers and actions

1.5. Creating views

1.6. Improving your application

1.7. Summary

Chapter 2. Presentation model

2.1. The M in MVC

2.2. Delivering the presentation model

2.3. ViewData.Model

2.4. Representing user input

2.4.1. Designing the model

2.4.2. Presenting the input model in a view

2.4.3. Working with the submitted input

2.5. More complex models for both display and input

2.5.1. Designing the model

2.5.2. Working with the input model

2.6. Summary

Chapter 3. View fundamentals

3.1. Introducing views

3.2. Examining the ViewDataDictionary

3.3. Strongly typed views with a view model

3.4. Displaying view model data in a view

3.5. Using strongly typed templates

3.5.1. EditorFor and DisplayFor templates

3.5.2. Built-in templates

3.5.3. Selecting templates

3.5.4. Customizing templates

3.6. Summary

Chapter 4. Controller basics

4.1. The anatomy of a controller

4.2. Storyboarding an application

4.3. Transforming a model to a view model

4.4. Accepting input

4.4.1. Handling the successful storyboard path in an action

4.4.2. Using the Post-Redirect-Get pattern

4.4.3. Handling the failure processing of the action input

4.5. Testing controllers

4.5.1. Testing the RedirectController

4.5.2. Making dependencies explicit

4.5.3. Using test doubles, such as stubs and mocks

4.5.4. Elements of a good controller unit test

4.6. Summary

Chapter 5. Consuming third-party components

5.1. The MvcContrib Grid component

5.1.1. Using the MvcContrib Grid

5.1.2. MvcContrib Grid advanced usage

5.2. The SlickUpload component

5.3. Summary

Chapter 6. Hosting ASP.NET MVC applications

6.1. Deployment scenarios

6.2. XCOPY deployment

6.3. Deploying to IIS 7

6.4. Deploying to IIS 6 and earlier

6.4.1. Configuring routes to use the .aspx extension

6.4.2. Configuring routes to use a custom extension

6.4.3. Using wildcard mapping with selective disabling

6.4.4. Using URL rewriting

6.5. Summary

Chapter 7. Leveraging existing ASP.NET features

7.1. ASP.NET server controls

7.1.1. The TextBox

7.1.2. Other common controls

7.1.3. The GridView

7.1.4. Where do I get the good stuff?

7.2. State management

7.2.1. Caching

7.2.2. Session state

7.2.3. Cookies

7.2.4. Request storage

7.3. Tracing and debugging

7.3.1. TraceContext

7.3.2. Health monitoring

7.4. Implementing personalization and localization

7.4.1. Leveraging ASP.NET personalization

7.4.2. Leveraging ASP.NET localization

7.5. Implementing ASP.NET site maps

7.6. Summary

2. Journeyman techniques

Chapter 8. Domain model

8.1. Understanding the basics of domain-driven design

8.2. A sample domain model

8.2.1. Key entities and value objects

8.2.2. Aggregates

8.2.3. Persistence for the domain model

8.3. Summary

Chapter 9. Extending the controller

9.1. Controller extensibility

9.2. Controller actions

9.3. Action, authorization, and result filters

9.4. Action selectors

9.5. Using action results to reduce complexity

9.5.1. Removing duplication with an action result

9.5.2. Using action results to abstract hard-to-test dependencies

9.6. Summary

Chapter 10. Advanced view techniques

10.1. Eliminating duplication in the view

10.1.1. Master pages

10.1.2. Partials

10.1.3. Child actions

10.2. Building query-string parameter lists

10.3. Exploring the Spark view engine

10.3.1. Installing and configuring Spark

10.3.2. Simple Spark view example

10.4. Summary

Chapter 11. Security

11.1. Authentication and authorization

11.1.1. Requiring authentication with AuthorizeAttribute

11.1.2. Requiring authorization with AuthorizeAttribute

11.1.3. AuthorizeAttribute—how it works

11.2. Cross-site scripting (XSS)

11.2.1. XSS in action

11.2.2. Avoiding XSS vulnerabilities

11.3. Cross-site request forgery (XSRF)

11.3.1. XSRF in action

11.3.2. Preventing XSRF

11.3.3. JSON hijacking

11.4. Summary

Chapter 12. Ajax in ASP.NET MVC

12.1. Diving into Ajax with an example

12.2. Ajax with ASP.NET Web Forms

12.3. Ajax in ASP.NET MVC

12.3.1. Introducing jQuery

12.3.2. Implementing the Hijax technique

12.3.3. Ajax with JSON

12.3.4. Adding alternate view formats to the controller

12.3.5. Consuming a JSON action from the view

12.3.6. Ajax helpers

12.4. Summary

Chapter 13. Controller factories

13.1. What are controller factories?

13.2. Creating a custom controller factory

13.3. Enabling dependency injection in your controllers

13.4. Creating a StructureMap controller factory

13.5. Creating a Ninject controller factory

13.6. Creating a Castle Windsor controller factory

13.7. Summary

Chapter 14. Model binders and value providers

14.1. Creating a custom model binder

14.2. Using custom value providers

14.3. Summary

Chapter 15. Validation

15.1. Validation with Data Annotations

15.2. Extending the ModelMetadataProvider

15.3. Client-side validation with ASP.NET Ajax

15.4. Summary

3. Mastering ASP.NET MVC

Chapter 16. Routing

16.1. What are routes?

16.1.1. What’s that curl command?

16.1.2. Taking back control of the URL with routing

16.2. Designing a URL schema

16.2.1. Make simple, clean URLs

16.2.2. Make hackable URLs

16.2.3. Allow URL parameters to clash

16.2.4. Keep URLs short

16.2.5. Avoid exposing database IDs wherever possible

16.2.6. Consider adding unnecessary information

16.3. Implementing routes in ASP.NET MVC

16.3.1. URL schema for an online store

16.3.2. Adding a custom static route

16.3.3. Adding a custom dynamic route

16.3.4. Catchall routes

16.4. Using the routing system to generate URLs

16.5. Testing route behavior

16.6. Using routing with existing ASP.NET projects

16.7. Summary

Chapter 17. Deployment techniques

17.1. Employing continuous integration

17.2. Enabling push-button XCOPY deployments

17.3. Managing environment configurations

17.4. Enabling remote server deployments with Web Deploy

17.5. Summary

Chapter 18. Mapping with AutoMapper

18.1. Introducing AutoMapper

18.2. Life before AutoMapper

18.3. AutoMapper basics

18.3.1. AutoMapper Initialization

18.3.2. AutoMapper profiles

18.3.3. Sanity checking

18.3.4. Reducing repetitive formatting code

18.3.5. Another look at our views

18.4. Summary

Chapter 19. Lightweight controllers

19.1. Why lightweight controllers?

19.1.1. Maintainability

19.1.2. Testability

19.1.3. Focusing on the controller’s responsibility

19.2. Managing common view data

19.3. Deriving action results

19.4. Using an application bus

19.5. Summary

Chapter 20. Full system testing

20.1. Testing the user interface layer

20.1.1. Installing the testing software

20.1.2. Walking through the test manually

20.1.3. Automating the test

20.1.4. Running the test

20.2. Building maintainable navigation

20.3. Interacting with forms

20.4. Asserting results

20.5. Summary

Chapter 21. Organization with areas

21.1. Creating a basic area

21.2. Managing links and URLs with T4MVC

21.3. Summary

Chapter 22. Portable areas

22.1. Understanding the portable area

22.2. A simple portable area

22.3. Consuming portable areas

22.4. Creating an RSS widget with a portable area

22.5. Distributing the RssWidget

22.6. Interacting with the portable area bus

22.7. Summary

Chapter 23. Data access with NHibernate

23.1. Functional overview of reference implementation

23.2. Application architecture overview

23.3. Domain model—the application core

23.4. NHibernate configuration—infrastructure of the application

23.4.1. NHibernate’s configuration

23.4.2. The NHibernate mapping—simple but powerful

23.4.3. Initializing the configuration

23.5. UI is the presentation of the model

23.6. Pulling it together

23.7. Summary

4. Cross-cutting advanced topics

Chapter 24. Debugging routes

24.1. Extending the routing system

24.2. Inspecting routes at runtime

24.3. Summary

Chapter 25. Customizing Visual Studio for ASP.NET MVC

25.1. Creating custom T4 templates

25.2. Adding a custom test project template to the new project wizard

25.3. Summary

Chapter 26. Testing practices

26.1. Testing routes

26.2. Avoiding test complexity

26.3. Testing controllers

26.4. Testing model binders

26.5. Testing action filters

26.6. Summary

Chapter 27. Recipe: creating an autocomplete text box

27.1. Creating the basic autocomplete text box

27.2. Styling the results

27.3. Summary

Index

List of Figures

List of Tables

List of Listings