You are previewing Programming Microsoft® ASP.NET 4.
O'Reilly logo
Programming Microsoft® ASP.NET 4

Book Description

Completely reengineered for ASP.NET 4—this definitive guide deftly illuminates the core architecture and programming features of ASP.NET 4 in a single, pragmatic volume. Web development expert Dino Esposito provides essential, architectural-level guidance, along with the in-depth technical insights designed to take you—and your solutions—to the next level. The book covers Dynamic Data, AJAX, Microsoft Silverlight, ASP.NET MVC, Web forms, LINQ, and security strategies—and features extensive code samples in Microsoft Visual C#(R) 2010.

Table of Contents

  1. Programming Microsoft® ASP.NET 4
  2. Dedication
  3. A Note Regarding Supplemental Files
  4. Acknowledgments
  5. Introduction
    1. Who Should Read This Book?
    2. System Requirements
    3. Code Samples
    4. Errata & Book Support
    5. We Want to Hear from You
    6. Stay in Touch
  6. I. The ASP.NET Runtime Environment
    1. 1. ASP.NET Web Forms Today
      1. The Age of Reason of ASP.NET Web Forms
        1. The Original Strengths
          1. Page Postbacks
          2. The View State
          3. Server Controls
        2. Today’s Perceived Weaknesses
          1. More Control over HTML
          2. Separation Between Processing and Rendering
          3. Lightweight Pages
        3. How Much Is the Framework and How Much Is It You?
          1. The Page Controller Pattern
          2. Revisiting the Page Controller Pattern
      2. The AJAX Revolution
        1. Moving Away from Classic ASP.NET
          1. What’s a Paradigm Shift?
          2. The AJAX Paradigm Shift
          3. The Data-for-Data Model
          4. What Web Do We Want for Developers?
        2. AJAX as a Built-in Feature of the Web
          1. Selective Updates
          2. Direct Scripting
      3. ASP.NET of the Future
        1. ASP.NET MVC
          1. ASP.NET MVC Highlights
          2. A Runtime for Two
          3. Control over Markup
          4. ASP.NET MVC and Simplicity
        2. ASP.NET Web Pages
          1. Small, Simple, and Seamless
          2. Code and View Together
      4. Summary
    2. 2. ASP.NET and IIS
      1. The Web Server Environment
        1. A Brief History of ASP.NET and IIS
          1. The Standalone ASP.NET Worker Process
          2. The IIS Native Worker Process
          3. A Shared Pipeline of Components
        2. The Journey of an HTTP Request in IIS
          1. Events in the Request Life Cycle
          2. ASP.NET Request Processing in Integrated Pipeline Mode
          3. Building a Response for the Request
          4. Adding Your Own Code to the Pipeline
        3. Some New Features in IIS 7.5
          1. Autostarting Web Applications
          2. Application Pool Custom Identities
      2. Deploying ASP.NET Applications
        1. XCopy Deployment for Web Sites
          1. The Copy Web Site Function of Visual Studio 2010
          2. Copying Files
          3. Building a Setup Project
        2. Packaging Files and Settings
          1. The Web Deployment Tool
          2. Building a WDT Package
          3. Propagating IIS Settings
          4. Web.config Transformations
        3. Site Precompilation
          1. In-Place Precompilation
          2. Precompilation for Deployment
        4. Configuring IIS for ASP.NET Applications
          1. Recycling Policies
          2. Unexpected Restarts
          3. Output Caching Settings
        5. Application Warm-up and Preloading
          1. Behavior of a Warmed-up Application Pool
          2. Setting Up the Application Pool
          3. Specifying the Warm-up Code
      3. Summary
    3. 3. ASP.NET Configuration
      1. The ASP.NET Configuration Hierarchy
        1. Configuration Files
          1. The Tree of Configuration Files
          2. The Configuration Schema
          3. Sections and Section Groups
        2. The <location> Section
          1. Centralized Configuration
          2. Machinewide Settings
          3. Unmodifiable Settings
        3. The <system.web> Section
          1. The <anonymousIdentification> Section
          2. The <authentication> Section
          3. The <authorization> Section
          4. The <browserCaps> Section
          5. The <caching> Section
          6. The <customErrors> Section
          7. The <deployment> Section
          8. The <globalization> Section
          9. The <httpHandlers> Section
          10. The <httpModules> Section
          11. The <healthMonitoring> Section
          12. The <hostingEnvironment> Section
          13. The <httpCookies> Section
          14. The <httpRuntime> Section
          15. The <identity> Section
          16. The <machineKey> Section
          17. The <membership> Section
          18. The <pages> Section
          19. The <processModel> Section
          20. The <profile> Section
          21. The <roleManager> Section
          22. The <securityPolicy> Section
          23. The <sessionState>Section
          24. The <siteMap> Section
          25. The <trace> Section
          26. The <trust> Section
          27. The <urlMappings> Section
          28. The <webControls> Section
          29. The <xhtmlConformance> Section
        4. Other Top-Level Sections
          1. The <appSettings> Section
          2. The <connectionStrings> Section
          3. The <configProtectedData> Section
          4. The <system.web.extensions> Section
          5. The <system.webServer> Section
      2. Managing Configuration Data
        1. Using the Configuration API
          1. Retrieving Web Configuration Settings
          2. Retrieving Application Settings
          3. Updating Application Settings
        2. Encrypting a Section
          1. Using a Command-Line Tool
          2. Using a Programmatic Approach
          3. Choosing the Encryption Provider
          4. Creating Custom Configuration Sections
      3. Summary
    4. 4. HTTP Handlers, Modules, and Routing
      1. Writing HTTP Handlers
        1. The IHttpHandler Interface
          1. Members of the IHttpHandler Interface
          2. A Very Simple HTTP Handler
          3. Registering the Handler
          4. Preconditions for Managed Handlers
          5. Handlers Serving New Types of Resources
        2. The Picture Viewer Handler
          1. Designing the HTTP Handler
          2. Implementing the HTTP Handler
        3. Serving Images More Effectively
          1. Loading Images from Databases
          2. Serving Dynamically Generated Images
          3. Writing Copyright Notes on Images
          4. Controlling Images via an HTTP Handler
        4. Advanced HTTP Handler Programming
          1. Deploying Handlers as ASHX Resources
          2. Prevent Access to Forbidden Resources
          3. Should It Be Reusable or Not?
          4. HTTP Handler Factories
          5. Asynchronous Handlers
          6. Implementing Asynchronous Handlers
      2. Writing HTTP Modules
        1. The IHttpModule Interface
        2. A Custom HTTP Module
          1. Wiring Up Events
          2. Registering with the Configuration File
          3. Accessing Other HTTP Modules
        3. Examining a Real-World HTTP Module
          1. The UrlRoutingModule Class
          2. The PostResolveRequestCache Event
      3. URL Routing
        1. The URL Routing Engine
          1. Original URL Rewriting API
          2. URL Patterns and Routes
        2. Routing in Web Forms
          1. Defining Routes for Specific Pages
          2. Programmatic Access to Route Values
          3. Structure of Routes
          4. Preventing Routing for Defined URLs
      4. Summary
  7. II. ASP.NET Pages and Server Controls
    1. 5. Anatomy of an ASP.NET Page
      1. Invoking a Page
        1. The Runtime Machinery
          1. Resource Mappings
          2. Representing the Requested Page
          3. Partial Classes in ASP.NET Projects
        2. Processing the Request
          1. The HttpRuntime Class
          2. The Application Factory
          3. The HttpApplication Object
          4. The Page Factory
        3. The Processing Directives of a Page
          1. The @Page Directive
          2. The @Assembly Directive
          3. The @Import Directive
          4. The @Implements Directive
          5. The @Reference Directive
      2. The Page Class
        1. Properties of the Page Class
          1. Intrinsic Objects
          2. Worker Properties
          3. Context Properties
        2. Methods of the Page Class
          1. Rendering Methods
          2. Controls-Related Methods
          3. Script-Related Methods
        3. Events of the Page Class
        4. The Eventing Model
          1. Introducing the View State
          2. The Single Form Model
        5. Asynchronous Pages
          1. The Async Attribute
          2. The AddOnPreRenderCompleteAsync Method
          3. The Significance of PreRenderComplete
          4. Building a Sample Asynchronous Page
          5. The RegisterAsyncTask Method
          6. Choosing the Right Approach
          7. Async-Compliant Operations
      3. The Page Life Cycle
        1. Page Setup
          1. The PreInit Event
          2. The Init Event
          3. The InitComplete Event
          4. View-State Restoration
          5. Processing Posted Data
          6. The PreLoad Event
          7. The Load Event
          8. Handling Dynamically Created Controls
        2. Handling the Postback
          1. Detecting Control State Changes
          2. Executing the Server-Side Postback Event
          3. The LoadComplete Event
        3. Page Finalization
          1. The PreRender Event
          2. The PreRenderComplete Event
          3. The SaveStateComplete Event
          4. Generating the Markup
          5. The Unload Event
      4. Summary
    2. 6. ASP.NET Core Server Controls
      1. Generalities of ASP.NET Server Controls
        1. Properties of the Control Class
          1. Identifying a Server Control
          2. Client ID Modes
          3. ASP.NET Control Containers
          4. View State of Controls
          5. Visibility of a Server Control
        2. Methods of the Control Class
        3. Events of the Control Class
        4. Other Features
          1. Adaptive Rendering
          2. Getting CSS-Friendly HTML
          3. Browser-Sensitive Rendering
          4. Themeable Controls
      2. HTML Controls
        1. Generalities of HTML Controls
          1. The HtmlControl Base Class
          2. Working with HTML Attributes
          3. Hierarchy of HTML Controls
        2. HTML Container Controls
          1. Managing Header Information
          2. Linking External CSS Files
          3. Managing Meta Information
          4. Navigating to a URL
          5. Handling Events on the Server
          6. The HtmlSelect Control
          7. The HtmlTextArea Control
        3. HTML Input Controls
          1. Command Buttons
          2. Controlling Validation
          3. Detecting State Changes of Controls
          4. Uploading Files
        4. The HtmlImage Control
      3. Web Controls
        1. Generalities of Web Controls
          1. Properties of Web Controls
          2. Styling Web Controls
          3. Managing the Style of Web Controls
          4. Methods of Web Controls
        2. Core Web Controls
          1. Button Controls
          2. HyperLinks
          3. Images and Image Buttons
          4. Check Boxes and Radio Buttons
          5. Text Controls
          6. Hidden Fields and File Upload
        3. Miscellaneous Web Controls
          1. The AdRotator Control
          2. The Calendar Control
          3. The Xml Control
          4. The PlaceHolder Control
          5. View Controls
      4. Summary
    3. 7. Working with the Page
      1. Dealing with Errors in ASP.NET Pages
        1. Basics of Exception Handling
          1. Exceptions in Action
          2. Guidelines for Exception Handling
        2. Basics of Page Error Handling
          1. Default Error Pages
          2. Page-Level Error Handling
          3. Global Error Handling
          4. Logging Exceptions
          5. Robust Error Handling
        3. Mapping Errors to Pages
          1. The <customErrors> Section
          2. Using Custom Error Pages
          3. Handling Common HTTP Errors
          4. Getting Information About the Exception
        4. Error Reporting
          1. Features of an Error Reporting System
          2. Error Reporting Tools
          3. Self-Logging Exceptions
      2. Page Personalization
        1. Creating the User Profile
          1. Definition of the Data Model in a Web Site Project
          2. The User Profile Class Representation
          3. Using Collection Types
          4. Using Custom Types
          5. Grouping Properties
          6. Definition of the Data Model in a WAP Project
        2. Interacting with the Page
          1. Creating the Profile Database
          2. Working with Anonymous Users
          3. Accessing Profile Properties
          4. User Profiles in Action
          5. Personalization Events
          6. Migrating Anonymous Data
        3. Profile Providers
          1. Configuring Profile Providers
          2. Structure of AspNetDb.mdf
          3. Custom Profile Providers
      3. Page Localization
        1. Making Resources Localizable
          1. Global and Local Resources
          2. Using Resources: Declarative vs. Programmatic
          3. Dealing with Global Resources
          4. Dealing with Local Resources
        2. Resources and Cultures
          1. Setting the Current Culture in .NET Applications
          2. Setting the Current Culture in ASP.NET Pages
          3. Changing Culture on the Fly
      4. Adding Resources to Pages
        1. Using Script Files
          1. Scripts at the Bottom of the Page
          2. Using a Content Delivery Network
          3. Reasons for Minifying a Script File
          4. Localized Scripts
        2. Using Cascading Style Sheets and Images
          1. Grouping Images into Sprites
          2. External References vs. Inline Content
      5. Summary
    4. 8. Page Composition and Usability
      1. Page Composition Checklist
        1. Working with Master Pages
          1. What’s a Master Page, Anyway?
          2. The @Master Directive
          3. The ContentPlaceHolder Container Control
          4. Specifying Default Content
        2. Writing a Content Page
          1. The Content Control
          2. Content Pages and Auxiliary Content
          3. Attaching Pages to a Master
          4. Device-Specific Masters
        3. Processing Master and Content Pages
          1. Compiling Master Pages
          2. Serving the Page to Users
          3. Nested Master Pages
        4. Programming the Master Page
          1. Exposing Master Properties
          2. Invoking Properties on the Master
          3. The @MasterType Directive
          4. Changing the Master Page Dynamically
        5. Styling ASP.NET Pages
          1. What’s a Theme, Anyway?
          2. Structure of a Theme
          3. Theming Pages and Controls
          4. Applying Skins
          5. Taking Control of Theming
          6. Loading Themes Dynamically
      2. Page Usability Checklist
        1. Cross-Browser Rendering
          1. Detecting Browser Capabilities
          2. Browser Definition Files
          3. Browser Capabilities Providers
        2. Search Engine Optimization
          1. Quick SEO Checklist
          2. SEO and ASP.NET
          3. Tools for Measuring SEO Level
        3. Site Navigation
          1. Defining Site Map Information
          2. Site Map Providers
          3. The SiteMap Class
          4. The SiteMapPath Control
        4. Configuring the Site Map
          1. Using Multiple Site Map Files
          2. Securing ASP.NET Site Maps
          3. Localizing Site Map Information
          4. Localizing the Site Navigation Structure
        5. Testing the Page
          1. Testing the Logic of the Page
          2. Testing the Client-Side Behavior of the Page
          3. Testing Posted Data
      3. Summary
    5. 9. ASP.NET Input Forms
      1. Programming with Forms
        1. The HtmlForm Class
          1. Properties of the HtmlForm Class
          2. Methods of the HtmlForm Class
        2. Multiple Forms
          1. Using HTML Forms
          2. Nested HTML Forms
          3. Multiple Server <form> Tags on a Page
          4. Multiple View and Wizards
        3. Cross-Page Postings
          1. Posting Data to Another Page
          2. The @PreviousPageType Directive
          3. Detecting Cross-Page Postings
          4. Redirecting Users to Another Page
      2. Validation Controls
        1. Generalities of Validation Controls
          1. The BaseValidator Class
          2. Associating Validators with Input Controls
        2. Gallery of Controls
          1. The CompareValidator Control
          2. The CustomValidator Control
          3. The RegularExpressionValidator Control
          4. The RangeValidator Control
          5. The RequiredFieldValidator Control
        3. Special Capabilities
          1. Server-Side Validation
          2. Displaying Error Information
          3. Multiple Validators per Control
          4. The ValidationSummary Control
          5. Enabling Client Validation
          6. Validation Groups
          7. Dealing with Validation in Cross-Page Posts
      3. Working with Wizards
        1. An Overview of the Wizard Control
          1. Structure of a Wizard
          2. Wizard Styles and Templates
          3. The Wizard’s Programming Interface
        2. Adding Steps to a Wizard
          1. Types of Wizard Steps
          2. Creating an Input Step
          3. Defining the Sidebar
        3. Navigating Through the Wizard
          1. Filtering Page Navigation with Events
          2. Canceling Events
          3. Finalizing the Wizard
      4. Summary
    6. 10. Data Binding
      1. Foundation of the Data Binding Model
        1. Feasible Data Sources
          1. Collection Classes
          2. ADO.NET Classes
          3. Queryable Objects
        2. Data-Binding Properties
          1. The DataSource Property
          2. The DataSourceID Property
          3. The DataMember Property
          4. The DataTextField Property
          5. The DataValueField Property
          6. The AppendDataBoundItems Property
          7. The DataKeyField Property
      2. Data-Bound Controls
        1. List Controls
          1. The DropDownList Control
          2. The CheckBoxList Control
          3. The RadioButtonList Control
          4. The ListBox Control
          5. The BulletedList Control
        2. Iterative Controls
          1. The Repeater Control
          2. The DataList Control
          3. The DataGrid Control
        3. View Controls
          1. The DetailsView Control
          2. The FormView Control
          3. The GridView Control
          4. The ListView Control
      3. Data-Binding Expressions
        1. Simple Data Binding
          1. Binding in Action
          2. Implementation of Data-Binding Expressions
        2. The DataBinder Class
          1. The Eval Method
          2. A More Compact Eval
          3. Getting the Default Data Item
      4. Managing Tables of Data
        1. The GridView’s Object Model
          1. Events of the GridView Control
        2. Binding Data to the Grid
          1. Configuring Columns
          2. Bound Fields
          3. Button Fields
          4. Hyperlink Fields
          5. Check Box Fields
          6. Image Fields
          7. Templated Fields
        3. Working with the GridView
          1. Paging Data
          2. Sorting Data
          3. Editing Data
      5. Data Source Components
        1. Internals of Data Source Controls
          1. Data Source Views
          2. Hierarchical Data Source Views
        2. The ObjectDataSource Control
          1. Programming Interface of ObjectDataSource
          2. Implementing Data Retrieval
          3. Using Parameters
          4. Caching Data and Object Instances
          5. Setting Up for Paging
          6. Updating and Deleting Data
          7. Configuring Parameters at Runtime
      6. Summary
    7. 11. The ListView Control
      1. The ListView Control
        1. The ListView Object Model
          1. Properties of the ListView Control
          2. Events of the ListView Control
          3. Compared to Other View Controls
          4. Simple Data Binding
        2. Defining the Layout of the List
        3. Building a Tabular Layout
          1. Definition of the Overall Layout
          2. Definition of the Item Template
          3. Using Alternate Rendering for Data Items
          4. Reflecting On the Table Layout
        4. Building a Flow Layout
          1. Definition of the Overall Layout
          2. Definition of the Item Layout
        5. Building a Tiled Layout
          1. Grouping Items
          2. Using the Group Separator Template
          3. Modifying the Group Item Count Dynamically
          4. Data-Driven Group Templates
        6. Styling the List
          1. Style Properties
          2. Using Cascading Style Sheets
      2. Working with the ListView Control
        1. In-Place Editing
          1. Defining the Edit Item Template
          2. Adding Predefined Command Buttons
          3. Adding Custom Command Buttons
        2. Conducting the Update
          1. Deleting an Existing Record
          2. Showing a Message Box upon Completion
        3. Inserting New Data Items
          1. Setting Up the Insert Item Template
          2. Taking Full Control of the Insert Template
          3. Adding a Bit of Validation
        4. Selecting an Item
          1. Triggering the Selection
          2. Releasing the Selection
        5. Paging the List of Items
          1. The DataPager Control
          2. Using the DataPager Control
          3. Configuring the Data Pager Fields
          4. Pageable Containers
          5. Sorting the List
      3. Summary
    8. 12. Custom Controls
      1. Extending Existing Controls
        1. Choosing a Base Class
          1. Inheriting from a Base Class
          2. Extending a Base Class
        2. A Richer HyperLink Control
          1. Designing a Usage Scenario
          2. A Redirector for the HyperLink Control
      2. Building Controls from Scratch
        1. Base Class and Interfaces
          1. Control vs. WebControl
          2. Related Interfaces
        2. Choosing a Rendering Style
          1. The Render Method
          2. Building the Control Tree
        3. The SimpleGaugeBar Control
          1. Defining the Object Model
          2. Implementing the Object Model
          3. Setting Up the Ruler
          4. Setting Up the Control’s Site
        4. Rendering the SimpleGaugeBar Control
          1. Generating the HTML for a Custom Control
          2. Using Child Controls for Rendering
          3. The Gauge in Action
      3. Building a Data-Bound Control
        1. Key Features
          1. Adding Data-Bound Properties
          2. Adding a Data Item Property
          3. Overriding the PerformDataBinding Method
        2. The GaugeBar Control
          1. Mapping Data Source Fields to Control Properties
          2. The GaugeBar’s Data Item Object
          3. Data Item and View State
          4. Ad Hoc View-State Management
          5. Getting Bound Data
      4. Building a Composite Templated Control
        1. Generalities of Composite Data-Bound Controls
          1. Creating a Hierarchy of Child Controls
          2. The Overloaded CreateChildControls
          3. The Control Item
        2. The BarChart Control
          1. The BarChart Item Object
          2. Adding Bound Data
          3. Events of the BarChart Control
          4. Using the BarChart Control
        3. Adding Template Support
          1. Templates and User Controls
          2. Defining a Template Property
          3. Defining a Template Container
          4. Setting a Template Property
          5. Rendering a Template
      5. Summary
  8. III. Design of the Application
    1. 13. Principles of Software Design
      1. The Big Ball of Mud
        1. Reasons for the Mud
          1. Limited Skills
          2. Requirements Churn
          3. Members Turnover
        2. Alarming Symptoms
          1. Make a Change Here, Break the Code There
          2. Easier to Use Than to Reuse
          3. Easier to Work Around Than to Fix
      2. Universal Software Principles
        1. Cohesion and Coupling
          1. Cohesion at a Glance
          2. Coupling at a Glance
        2. Separation of Concerns
          1. Identifying the Concerns
          2. Modularity
          3. Information Hiding
      3. SOLID Principles
        1. The Single Responsibility Principle
          1. SRP Canonical Example
          2. SRP Real-World Considerations
        2. The Open/Closed Principle
          1. OCP Canonical Example
          2. OCP Real-World Considerations
        3. Liskov’s Substitution Principle
          1. Substitution Principle Canonical Example
          2. Substitution Principle Real-World Considerations
        4. The Interface Segregation Principle
          1. Interface Segregation Canonical Example
          2. Interface Segregation Real-World Considerations
        5. The Dependency Inversion Principle
          1. Dependency Inversion Canonical Example
          2. Dependency Inversion Real-World Considerations
      4. Tools for Dependency Injection
        1. Managed Extensibility Framework at a Glance
          1. MEF vs. IoC
          2. Should You Choose MEF or an IoC?
          3. MEF in Action
        2. Unity at a Glance
          1. Registering Types and Instances
          2. Resolving Dependencies
          3. Declarative Configuration
          4. Lifetime Managers
      5. Summary
    2. 14. Layers of an Application
      1. A Multitiered Architecture
        1. The Overall Design
        2. Methodologies
      2. The Business Layer
        1. Design Patterns for the BLL
          1. The Transaction Script Pattern
          2. The Table Module Pattern
          3. The Active Record Pattern
          4. The Domain Model Pattern
        2. The Application Logic
          1. The Service Layer Pattern
          2. When the Application Logic Is Deployed Remotely
          3. Exposing Entities to the Presentation Layer
          4. Data Transfer Objects
      3. The Data Access Layer
        1. Implementation of a DAL
          1. DAL and the Table Module Pattern
          2. DAL and the Active Record Pattern
          3. DAL and the Domain Model Pattern
        2. Interfacing the DAL
          1. Support for Multiple Databases
          2. The Repository Pattern
        3. Using an Object/Relational Mapper
          1. LINQ-to-SQL
          2. Entity Framework
          3. NHibernate
          4. O/RM Tools and SQL Code
        4. Beyond Classic Databases
          1. Going to the Cloud
          2. Microsoft Dynamics CRM 2011
          3. Schema-less Storage
      4. Summary
    3. 15. The Model-View-Presenter Pattern
      1. Patterns for the Presentation Layer
        1. The MVC Pattern
          1. Generalities of the MVC Pattern
          2. Role of the Model
          3. Role of the View
          4. Role of the Controller
          5. Web Forms and the MVC Pattern
        2. The MVP Pattern
          1. Generalities of the MVP Pattern
          2. Role of the Model
          3. Role of the View
          4. Role of the Presenter
          5. Web Forms and the MVP Pattern
        3. The MVVM Pattern
          1. Generalities of the MVVM Pattern
          2. Web Forms and MVVM
      2. Implementing Model View Presenter
        1. Abstracting the View
          1. From Use-Cases to the View
          2. Implementing the Interface
        2. Creating the Presenter
          1. Getting a Presenter’s Instance
          2. Using the Presenter
          3. How Does the Presenter Retrieve Data?
          4. Connecting the Presenter to the Service Layer
          5. Presenter in Action
          6. Sharing the Presenter with a Windows Application
        3. Navigation
          1. The Application Controller Pattern
          2. Defining the Navigation Workflow
          3. Navigating Within a Web Forms Site
      3. Testability in Web Forms with MVP
        1. Writing Testable Code
          1. Aspects of Testable Code
          2. Unit Testing
          3. Test-Driven Development
        2. Testing a Presenter Class
          1. Creating a Unit Test
          2. Testing Presenters in Isolation
      4. Summary
  9. IV. Infrastructure of the Application
    1. 16. The HTTP Request Context
      1. Initialization of the Application
        1. Properties of the HttpApplication Class
        2. Application Modules
        3. Methods of the HttpApplication Class
        4. Events of the HttpApplication Class
      2. The global.asax File
        1. Compiling global.asax
        2. Syntax of global.asax
          1. Application Directives
          2. Code Declaration Blocks
          3. Server-Side <object> Tags
          4. Static Properties
      3. The HttpContext Class
        1. Properties of the HttpContext Class
        2. Methods of the HttpContext Class
          1. URL Rewriting
          2. Loading Resources Programmatically
      4. The Server Object
        1. Properties of the HttpServerUtility Class
        2. Methods of the HttpServerUtility Class
          1. Embedding Another Page’s Results
          2. Server-Side Redirection
      5. The HttpResponse Object
        1. Properties of the HttpResponse Class
          1. Setting the Response Cache Policy
          2. Setting an Output Filter
        2. Methods of the HttpResponse Class
          1. Output Caching Features
          2. Large File Transmission
      6. The HttpRequest Object
        1. Properties of the HttpRequest Class
          1. Information About the Request
          2. Information from the Client
          3. Information About the Connection
        2. Methods of the HttpRequest Class
          1. Saving the Request to Disk
          2. Validating Client Input
      7. Summary
    2. 17. ASP.NET State Management
      1. The Application’s State
        1. Properties of the HttpApplicationState Class
        2. Methods of the HttpApplicationState Class
        3. State Synchronization
        4. Tradeoffs of Application State
      2. The Session’s State
        1. The Session-State HTTP Module
          1. State Client Managers
          2. Creating the HttpSessionState Object
          3. Synchronizing Access to the Session State
        2. Properties of the HttpSessionState Class
        3. Methods of the HttpSessionState Class
      3. Working with a Session’s State
        1. Identifying a Session
          1. Generating the Session ID
          2. Session Cookies
          3. Cookieless Sessions
          4. Issues with Cookieless Sessions
          5. Cookieless Sessions and Security
          6. Cookieless Sessions and SEO
          7. Configuring the Session State
        2. Lifetime of a Session
          1. The Session_Start Event
          2. The Session_End Event
          3. Why Does My Session State Sometimes Get Lost?
        3. Persist Session Data to Remote Servers
          1. State Serialization and Deserialization
          2. Storing Session Data
          3. Configuring the StateServer Provider
        4. Persist Session Data to SQL Server
          1. Performance and Robustness
          2. Configuring Session State for SQL Server Support
          3. Creating the SQL Server Data Store
          4. Reverting to the Hosting Identity
      4. Customizing Session State Management
        1. Building a Custom Session State Provider
          1. Defining the Session State Store
          2. Locking and Expiration
          3. Replacing the Session Data Dictionary
          4. Registering a Custom Session State Provider
        2. Generating a Custom Session ID
          1. The Default Behavior
          2. A Homemade Session ID Manager
      5. The View State of a Page
        1. The StateBag Class
          1. View State Properties
          2. View State Methods
        2. Common Issues with View State
          1. Encrypting and Securing
          2. Machine Authentication Check
          3. Size Thresholds and Page Throughput
        3. Programming the View State
          1. Disabling View State
          2. Determining When to Disable View State
          3. The Control State
          4. Programming the Control State
          5. Keeping the View State on the Server
      6. Summary
    3. 18. ASP.NET Caching
      1. Caching Application Data
        1. The Cache Class
          1. Fundamental Aspects of the Cache Object
          2. Properties of the Cache Class
          3. Methods of the Cache Class
          4. An Interior View
        2. Working with the ASP.NET Cache
          1. Inserting New Items in the Cache
          2. Removing Items from the Cache
          3. Tracking Item Dependencies
          4. Defining a Removal Callback
          5. Setting the Item’s Priority
          6. Controlling Data Expiration
        3. Practical Issues
          1. Should I Cache or Should I Fetch?
          2. Building a Wrapper Cache Object
          3. Clearing the Cache
          4. Cache Synchronization
          5. Per-Request Caching
        4. Designing a Custom Dependency
          1. Extensions to the CacheDependency Base Class
          2. Getting Change Notifications
          3. The AggregateCacheDependency Class
        5. A Cache Dependency for XML Data
          1. Designing the XmlDataCacheDependency Class
          2. Implementing the Dependency
          3. Testing the Custom Dependency
        6. SQL Server Cache Dependency
          1. Taking Advantage of SQL Server Dependencies
      2. Distributed Cache
        1. Features of a Distributed Cache
          1. High Availability
          2. Topology
          3. Freshness of Data
          4. Integration with the Data Access Layer
        2. AppFabric Caching Services
          1. Fast Facts
          2. Architecture of Caching Services
          3. Client-Side Configuration of Caching Services
          4. Programming Caching Services
        3. Other Solutions
          1. Memcached
          2. SharedCache
          3. Commercial Solutions
      3. Caching ASP.NET Pages
        1. ASP.NET and the Browser Cache
          1. Typical Behavior of the Browser Cache
          2. Typical Behavior of an ASP.NET Page
          3. Typical Behavior of Static Resources
        2. Making ASP.NET Pages Cacheable
          1. The @OutputCache Directive
          2. Choosing a Location for the Page Output
          3. Choosing a Duration for ASP.NET Page Output
          4. IIS Kernel Caching
          5. Adding a Database Dependency to Page Output
        3. The HttpCachePolicy Class
          1. Properties of the HttpCachePolicy Class
          2. Methods of the HttpCachePolicy Class
          3. Server Cache-Validation Callback
        4. Caching Multiple Versions of a Page
          1. Vary by Parameters
          2. Dealing with Postback Pages
          3. Vary by Headers
          4. Vary by Custom Strings
        5. Caching Portions of ASP.NET Pages
          1. What’s a User Control, Anyway?
          2. Caching the Output of User Controls
          3. Vary by Controls
          4. The Shared Attribute
          5. Fragment Caching in Cacheable Pages
        6. Advanced Caching Features
          1. Caching Profiles
          2. Post-Cache Substitution
          3. Output Cache Providers
      4. Summary
    4. 19. ASP.NET Security
      1. Where the Threats Come From
      2. The ASP.NET Security Context
        1. Who Really Runs My ASP.NET Application?
          1. IIS Thread Security Context
          2. Worker Process Security Context
          3. ASP.NET Pipeline Security Context
        2. Changing the Identity of the ASP.NET Process
          1. Setting the Process Account
          2. Impersonating a Fixed Identity
          3. Impersonating Through the Anonymous Account
          4. Privileges of the ASP.NET Default Account
        3. The Trust Level of ASP.NET Applications
          1. The <trust> Section
          2. ASP.NET Permissions
          3. Granting Privileges Beyond the Trust Level
        4. ASP.NET Authentication Methods
          1. Windows Authentication
          2. Using ACLs to Authorize Access
          3. Windows CardSpace
      3. Using Forms Authentication
        1. Forms Authentication Control Flow
          1. Collecting Credentials Through Login
          2. Authenticating the User
          3. Signing Out
        2. The FormsAuthentication Class
          1. Properties of the FormsAuthentication Class
          2. Methods of the FormsAuthentication Class
        3. Configuration of Forms Authentication
          1. The <forms> Section
          2. Cookie-Based Forms Authentication
          3. Cookieless Forms Authentication
          4. Options for Cookieless Authentication
        4. Advanced Forms Authentication Features
          1. Applications to Share Authentication Cookies
          2. External Applications to Authenticate Users
          3. Forms Authentication and Secured Sockets
          4. General Security Issues
          5. Creating a Custom Principal
      4. The Membership and Role Management API
        1. The Membership Class
          1. The Programming Interface of the Membership Class
          2. Setting Up Membership Support
          3. Validating Users
          4. Managing Users and Passwords
        2. The Membership Provider
          1. The ProviderBase Class
          2. The MembershipProvider Class
          3. Extending the Provider’s Interface
          4. A Custom Provider for Legacy Code
          5. Configuring a Membership Provider
        3. Managing Roles
          1. The Role Management API
          2. The Roles Class
          3. The Role Provider
      5. Quick Tour of Claims-Based Identity
        1. Claims-Based Identity
          1. Claims and Identity Providers
          2. The Authentication Workflow
          3. Claims and Policies
        2. Using Claims in ASP.NET Applications
          1. Picking Up the STS
          2. Configuring the ASP.NET Application
      6. Security-Related Controls
        1. The Login Control
          1. Setting Up the Login Control
          2. The Programming Interface of the Control
          3. Events of the Control
        2. The LoginName Control
        3. The LoginStatus Control
          1. Setting Up the LoginStatus Control
          2. The Programming Interface of the Control
        4. The LoginView Control
          1. The Programming Interface of the Control
          2. Creating a Login Template
          3. Creating Role-Based Templates
        5. The PasswordRecovery Control
          1. Requirements for Password Retrieval
          2. Retrieving a Password
        6. The ChangePassword Control
          1. User Authentication
          2. Password Change
        7. The CreateUserWizard Control
      7. Summary
  10. V. The Client Side
    1. 20. Ajax Programming
      1. The Ajax Infrastructure
        1. The Hidden Engine of Ajax
          1. The Classic Browser-Led Model
          2. The New Out-of-Band Model
          3. From Dynamic HTML to the Standard DOM
          4. The XMLHttpRequest Object
          5. Using the XMLHttpRequest Object
        2. JavaScript and Ajax
          1. Functional Programming in JavaScript
          2. Objects in JavaScript
          3. Using Closures
          4. Using Prototypes
          5. Cross-Domain Ajax
      2. Partial Rendering in ASP.NET
        1. The ScriptManager Control
          1. Properties of the ScriptManager Control
          2. Methods of the ScriptManager Control
          3. Events of the ScriptManager Control
          4. The ScriptManagerProxy Control
          5. Script Binding and Loading
          6. Handling Debug and Release Script Files
          7. Script Globalization
        2. The UpdatePanel Control
          1. The UpdatePanel Control at a Glance
          2. The Programming Interface of the Control
          3. Populating the Panel Programmatically
          4. Master Pages and Updatable Regions
      3. Considerations Regarding Partial Rendering
        1. Configuring for Conditional Refresh
          1. Detecting Postbacks from Child Controls
          2. Programmatic Updates
          3. Using Triggers
          4. Full Postbacks from Inside Updatable Panels
        2. Giving Feedback to the User
          1. The UpdateProgress Control
          2. Composing the Progress Screen
          3. Client-Side Events for Richer Feedback
          4. Disabling Visual Elements During Updates
          5. Aborting a Pending Update
        3. The Ins and Outs of Partial Rendering
          1. Issues with Concurrent Calls
          2. Issues with Polling
      4. REST and Ajax
        1. Scriptable Services
          1. The HTTP Façade
          2. WCF Services
          3. ASP.NET Web Services
          4. Discriminate Against Outsiders
          5. Trusting the HTTP Façade
        2. JSON Payloads
          1. JSON at a Glance
          2. Data Contracts
          3. Why JSON Is Preferable to XML
        3. JavaScript Client Code
          1. Getting a Proxy for the HTTP Façade
          2. Using the Proxy
          3. Remote Calls via Page Methods
      5. Summary
    2. 21. jQuery Programming
      1. Power to the Client
        1. Programming within the Browser
          1. Original Goals of the Language
          2. The Scripting Engine
          3. Flaws and Workarounds
          4. What You Write JavaScript Code For
        2. The Gist of jQuery
          1. Details of the Library
          2. The Root Object
          3. jQuery and Functional Programming
      2. Working with jQuery
        1. Detecting DOM Readiness
          1. The DOM ReadyState Property
          2. The jQuery’s Ready Function
          3. Onload vs. Ready
        2. Wrapped Sets
          1. Enumerating the Content
          2. Basic Selectors
          3. Compound Selectors
          4. Predefined Filters
          5. Form Filters
          6. Filter vs. Find
        3. Operating on a Wrapped Set
          1. Controlling Visibility
          2. Styling
          3. Binding and Unbinding Events
          4. Live Event Binding
        4. Manipulating the DOM
          1. Creating a DOM Tree
          2. Adding Elements to the DOM
          3. Removing DOM Elements
          4. Modifying DOM Elements
        5. The jQuery Cache
          1. Cached Data and DOM Elements
          2. Working with Data in the In-Memory Cache
        6. Ajax Capabilities
          1. Plain Ajax Caller
          2. Global Ajax Event Handlers
          3. Getting Scripts
          4. Getting JSON
          5. Getting HTML
        7. Cross-Domain Calls
          1. Cross-Domain HTML Tags
          2. Basics of JSONP
          3. JSONP in jQuery
      3. Summary
  11. Index
  12. About the Author
  13. Copyright