ASP.NET MVC 2 in Action
Jeffrey Palermo, Ben Scheirman, Jimmy Bogard, Eric Hexter, and Matthew Hinze
  • June 2010
  • ISBN 9781935182795
  • 432 pages
  • printed in black & white
This title is out of print and no longer for sale.

...learn from expert users of the ASP.NET MVC framework.

Rod Paddock,

Third edition of this book is available

ASP.NET MVC 2 in Action is a fast-paced tutorial designed to introduce the MVC model to ASP.NET developers and show how to apply it effectively. After a high-speed ramp up, the book presents over 25 concise chapters exploring key topics like validation, routing, and data access. Each topic is illustrated with its own example so it's easy to dip into the book without reading in sequence. This book covers some high-value, high-end techniques you won't find anywhere else!

Table of Contents show full

foreword

foreword to the first edition

preface

preface to the first edition

acknowledgments

about this book

about the authors

about the cover illustration

Part 1 High-speed fundamentals

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

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.5. More complex models for both display and input

2.6. Summary

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.6. Summary

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.5. Testing controllers

4.6. Summary

5. Consuming third-party components

5.1. The MvcContrib Grid component

5.2. The SlickUpload component

5.3. Summary

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.5. Summary

7. Leveraging existing ASP.NET features

7.1. ASP.NET server controls

7.2. State management

7.3. Tracing and debugging

7.4. Implementing personalization and localization

7.5. Implementing ASP.NET site maps

7.6. Summary

Part 2 Journeyman techniques

8. Domain model

8.1. Understanding the basics of domain-driven design

8.2. A sample domain model

8.3. Summary

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.6. Summary

10. Advanced view techniques

10.1. Eliminating duplication in the view

10.2. Building query-string parameter lists

10.3. Exploring the Spark view engine

10.4. Summary

11. Security

11.1. Authentication and authorization

11.2. Cross-site scripting (XSS)

11.3. Cross-site request forgery (XSRF)

11.4. Summary

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.4. Summary

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

14. Model binders and value providers

14.1. Creating a custom model binder

14.2. Using custom value providers

14.3. Summary

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

Part 3 Mastering ASP.NET MVC

16. Routing

16.1. What are routes?

16.2. Designing a URL schema

16.3. Implementing routes in ASP.NET MVC

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

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

18. Mapping with AutoMapper

18.1. Introducing AutoMapper

18.2. Life before AutoMapper

18.3. AutoMapper basics

18.4. Summary

19. Lightweight controllers

19.1. Why lightweight controllers?

19.2. Managing common view data

19.3. Deriving action results

19.4. Using an application bus

19.5. Summary

20. Full system testing

20.1. Testing the user interface layer

20.2. Building maintainable navigation

20.3. Interacting with forms

20.4. Asserting results

20.5. Summary

21. Organization with areas

21.1. Creating a basic area

21.3. Summary

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

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.5. UI is the presentation of the model

23.6. Pulling it together

23.7. Summary

Part 4 Cross-cutting advanced topics

24. Debugging routes

24.1. Extending the routing system

24.2. Inspecting routes at runtime

24.3. Summary

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

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

27. Recipe: creating an autocomplete text box

27.1. Creating the basic autocomplete text box

27.2. Styling the results

27.3. Summary

index

© 2014 Manning Publications Co.

About the Technology

The future of high-end web development on the Microsoft platform, ASP.NET MVC 2 provides clear separation of data, interface, and logic and radically simplifies tedious page and event lifecycle management. And since it's an evolution of ASP.NET, you can mix MVC and Web Forms in the same application, building on your existing work.

About the book

Microsoft ASP.NET MVC (model/view/controller) is a relatively new Web application framework that combines ASP.NET's power and ease of use with the stability and testability of a MVC framework. The much-anticipated version 2 release brings new capabilities to the framework along with numerous additions that enhance developer productivity. In ASP.NET MVC 2 in Action, readers learn how to move from web form-based development to designs based on the MVC pattern. It begins with an introduction to the MVC framework and quickly dives into a working MVC 2 project.

Featuring full coverage of new version 2 features, this book helps readers use developer-oriented upgrades like "Areas" to break a large project into smaller pieces and explore the new data handling tools. This revised edition adds a completely new tutorial to bring developers with no prior exposure to the MVC pattern up to speed quickly, keeping its focus on providing high-quality, professional grade examples that go deeper than the other ASP.NET MVC books.

What's inside

  • Dozens of self-contained examples
  • Real-world use cases
  • Full-system testing for ASP.NET applications

About the authors

All authors are Microsoft MVPs and ASPInsiders. Jeffrey Palermo is cofounder of MvcContrib and CIO of Headspring Systems. Ben Scheirman, Jimmy Bogard, Eric Hexter (the other cofounder of MvcContrib), and Matthew Hinze are architects and .NET community leaders.