Home   FAQs   New Arrivals   Specials   Pricing & Shipping   Location   Corporate Services   Why Choose Bookware?  
Call our store: 9955 5567 (from within Sydney) or 1800 734 567 (from outside Sydney)
 View Cart   Check Out   
Browse by Subject
 TAFE Accounting
 TAFE I.T./Computing
 TAFE - Other
 Windows 8
 Adobe CS6
 CCNA 2012
 CCNP 2012
 Web Design
 Project Management
 Mobile Devices
 Windows Server 2012
 SQL Server 2012
Economics and Business
 Business Information Systems
 Human Resources

ASP.NET MVC Framework Unleashed

by: Stephen Walther

Notify me when in stock

On-line Price: $49.95 (includes GST)

Paperback package 504

10%Off Retail Price

You save: $5.00

This item is available to backorder. Usually ships within 3 - 4 weeks.

Retail Price: $54.95

Publisher: SAMS,04.08.09

Category: ASP Level:

ISBN: 0672329980
ISBN13: 9780672329982

Add to Shopping Cart

Features and Benefits


A practical reference to building applications with MVC (Model View Controller), a dramatic new model for building web apps in ASP.NET

  * The Model View Controller is a new framework from Microsoft for building ASP.NET applications

  * Most professional developers will want to learn about MVC

  * The author is one of the world's foremost authorities on ASP.NET, and one of the world's best teachers of ASP.NET

Table of Contents


Introduction 1

How This Book Is Organized


What You Should Know Before Reading This Book


What Software Do You Need?


Where Do You Download the Code Samples?


If You Like This Book


Part I Building ASP.NET MVC Applications

Chapter 1 An Introduction to ASP.NET MVC


A Story with a Moral


What Is Good Software?


Avoiding Code Smells


Software Design Principles


Software Design Patterns


Writing Unit Tests for Your Code


Test-Driven Development


Short-Term Pain, Long-Term Gain




ASP.NET MVC Is Part of the ASP.NET Framework


The Origins of MVC


The Architecture of an ASP.NET MVC Application


Understanding the Sample ASP.NET MVC Application


ASP.NET MVC Folder Conventions


Running the Sample ASP.NET MVC Application


Chapter 2 Building a Simple ASP.NET MVC Application 23

Starting with a Blank Slate


Creating the Database


Creating the Model


Creating the Controller


Creating the Views


Adding the Index View


Adding the Create View


Chapter 3 Understanding Controllers and Actions


Creating a Controller


Returning Action Results


Returning a View Result


Returning a Redirect Result


Returning a Content Result


Returning a JSON Result


Returning a File Result


Controlling How Actions Are Invoked


Using AcceptVerbs


Using ActionName


Using ActionMethodSelector


Handling Unknown Actions


Testing Controllers and Actions


Chapter 4 Understanding Views 83

Creating a View


Using View Data


Typed and Untyped Views


Creating Strongly Typed Views


Preventing JavaScript Injection Attacks


Using Alternative View Engines


Creating a Custom View Engine


Testing Views


Test the View Result


Test HTML Helpers


Test a Custom View Engine


Chapter 5 Understanding Models


Creating a Data Model


Creating a Data Model with the Microsoft Entity Framework


Listing Records


Getting a Single Record


Creating Records


Editing Records


Deleting Records


Using the Repository Pattern


Creating a Product Repository


Using the Dependency Injection Pattern


Creating a Generic Repository


Using the Generic Repository with the Entity Framework


Using the Generic Repository with LINQ to SQL


Extending the Generic Repository


Testing Data Access


Testing with a Mock Repository


Testing with a Fake Generic Repository


Chapter 6 Understanding HTML Helpers 159

Using the Standard HTML Helpers


Rendering Links


Rendering Image Links


Rendering Form Elements


Rendering a Form


Rendering a Drop-Down List


Encoding HTML Content


Using Antiforgery Tokens


Creating Custom HTML Helpers


Using the TagBuilder Class


Using the HtmlTextWriter Class


Creating a DataGrid Helper


Adding Sorting to the DataGrid Helper


Adding Paging to the DataGrid Helper


Testing Helpers


Chapter 7 Understanding Model Binders and Action Filters


Understanding Model Binders


Using the Default Model Binder


Binding to Complex Classes


Using the Bind Attribute


Using Bind with Classes


Using Prefixes When Binding


Using the Form Collection Model Binder


Using the HTTP Posted File Base Model Binder


Creating a Custom Model Binder


Understanding Action Filters


Creating a Log Action Filter


Chapter 8 Validating Form Data 241

Understanding Model State


Understanding the Validation Helpers


Styling Validation Error Messages


Prebinding and Postbinding Validation


Validating with a Service Layer


Validating with the IDataErrorInfo Interface


Testing Validation


Chapter 9 Understanding Routing


Using the Default Route


Debugging Routes


Creating Custom Routes


Creating Route Constraints


Using Regular Expression Constraints


Using the HttpMethod Constraint


Creating an Authenticated Constraint


Creating a NotEqual Constraint


Using Catch-All Routes


Testing Routes


Using the MvcFakes and RouteDebugger Assemblies


Testing If a URL Matches a Route


Testing Routes with Constraints


Chapter 10 Understanding View Master Pages and View User Controls


Understanding View Master Pages


Creating a View Master Page


Creating a View Content Page


Setting the Master Page from the Controller


Setting the Master Page Title


Nested Master Pages


Passing View Data to Master Pages


Understanding View User Controls


Passing View Data to User Controls


Using a View User Control as a Template


Chapter 11 Better Performance with Caching


Using the OutputCache Attribute


Don't Cache Private Data


What Gets Cached?


Setting the Cache Location


Varying the Output Cache by Parameter


Varying the Output Cache


Removing Items from the Output Cache


Using Cache Profiles


Using the Cache API


Using the HttpCachePolicy Class


Using the Cache Class


Testing the Cache


Testing the OutputCache Attribute


Testing Adding Data to the Cache


Chapter 12 Authenticating Users


Creating Users and Roles


Using the Web Site Administration Tool


Using the Account Controller


Authorizing Users


Using the Authorize Attribute


Using the User Property


Configuring Membership


Configuring the Membership Database


Configuring Membership Settings


Using the Membership and Role Manager API


Using Windows Authentication


Configuring Windows Authentication


Authenticating Windows Users and Groups


Testing Authorization


Testing for the Authorize Attribute


Testing with the User Model Binder


Chapter 13 Deploying ASP.NET MVC Applications


Configuring IIS for ASP.NET MVC


Integrated Versus Classic Mode


Using ASP.NET MVC with Older Versions of IIS


Adding Extensions to the Route Table


Hosted Server


Creating a Wildcard Script Map


Mixing ASP.NET Web Forms and ASP.NET MVC


Modifying the Visual Studio Project File


Adding the Required Assemblies


Modifying the Web Configuration File


Modify the Global.asax File


Using Web Forms and MVC


Bin Deploying an ASP.NET MVC Application


Chapter 14 Working with Ajax


Using the Ajax Helpers


Debugging Ajax


Posting a Form Asynchronously


Displaying Progress


Updating Content After Posting


Performing Validation


Providing Downlevel Browser Support


Retrieving Content Asynchronously


Highlighting the Selected Link


Creating a Delete Link


Providing Downlevel Browser Support


Using the AcceptAjax Attribute


Chapter 15 Using jQuery


Overview of jQuery


Including the jQuery Library


jQuery and Visual Studio Intellisense


Using jQuery Selectors


Adding Event Handlers


Using jQuery Animations


jQuery and Ajax


Using jQuery Plug-Ins


Part II Walkthrough: Building the Unleashed Blog Application

Chapter 16 Overview of the Application


What Is Test-Driven Development?


Why Do Test-Driven Development?


The KISS and YAGNI Principles


Waterfall Versus Evolutionary Design


TDD Tests Are Not Unit Tests


Tests Flow from User Stories


Unit Testing Frameworks


Bibliography of Test-Driven Development


Chapter 17 Database Access


Creating the Unleashed Blog Project


Creating Our First Test


Creating New Blog Entries


Refactoring to Use the Repository Pattern


Creating a Fake Blog Repository


Creating an Entity Framework Repository


Creating the Database Objects


Creating the Entity Framework Data Model


Creating the Entity Framework Blog Repository


Using the Entity Framework Repository


Chapter 18 Creating the Routes


Creating the Controller Tests


Creating the Route Tests


Creating the Archive Routes


Trying Out the Archive Controller


Chapter 19 Adding Validation 567

Performing Validation in the Simplest Possible Way


Refactoring the Test Code


Validating the Length of a Property


A Web Browser Sanity Check


Refactoring to Use a Service Layer


Adding Business Rules


Chapter 20 Paging, Views, and Ajax


Adding Paging Support


Adding the Views


Adding Ajax Support


Chapter 21 Adding Comments


Implementing Comments


Adding Comments to the Database


Displaying Comments and Comment Counts


Part III Appendixes

Appendix A C# and VB.NET Language Features


Type Inference


Object Initializers


Anonymous Types


Nullable Types


Extension Methods




Lambda Expressions




Appendix B Using a Unit Testing Framework


Using Visual Studio Unit Test


Understanding the Test Attributes


Using Assertions


Running the Tests


Limiting Visual Studio Test Results


Using NUnit


Creating an NUnit Unit Test Project


Creating a Test


Running Tests


Appendix C Using a Mock Object Framework 679

Understanding the Terminology


Installing Moq


Using Moq to Create a Class from an Interface


Returning Fake Values


About the Authors


Stephen Walther has lived a year in Borneo, taught classes on metaphysics at Harvard and MIT, helped found two successful startups, and has run a training and consulting company. He currently is a Program Manager on the Microsoft ASP.NET team where he works on the Microsoft Ajax framework. He has spoken at numerous conferences including PDC, MIX, TechEd, ASP.NET Connections, and VSLive.