Contents
What Is the Structure of This Book?
Part 2: Results and Parameters
Where Can You Get the Example Code?
How Do You Set Up a Development Environment?
Chapter 2: Your First Web API Application
Creating the Visual Studio Project
Adding and Updating NuGet Packages
Setting the Port and Start URL
Creating the Web API Controller
Testing the Web API Controller
Implementing the Single-Page Client
Setting Up JavaScript IntelliSense
Defining the Client-Side Data Model and Controller
Registering the JavaScript File
Testing the Single-Page Client
Measuring the Single-Page Implementation
Chapter 3: Essential Techniques
Adding and Updating NuGet Packages
Creating the Web API Controller
Creating the MVC Framework Controller
Setting the Port and Start URL
Understanding Asynchronous Methods
Understanding the Problem Asynchronous Methods Solve
Implementing an Asynchronous Interface
Creating a Self-Contained Asynchronous Method Body
Returning a Task from a Synchronous Method Body
Making Ajax Requests with jQuery
Understanding the $.ajax Method
Chapter 4: Understanding HTTP Web Services
Understanding Single-Page Applications
Understanding Native Applications
Understanding Shared-Model Applications
Understanding Service Applications
Understanding Simple Web Services
Understanding RESTful Web Services
Chapter 5: SportsStore: Preparation
Adding and Updating NuGet Packages
Creating the OWIN Startup Class
Creating the Product and Order Models
Creating the Repository Classes
Defining the User and Role Classes
Creating the Database Context Classes
Adding the Configuration Statements
Removing the Application Cookie
Chapter 6: SportsStore: A RESTful Application
Creating a RESTful Web Service
Testing the Products Web Service
Putting the Web Service in Context
Working with Regular C# Objects
Using the RESTful Action Method Convention
Securing the Product Web Service
Restricting Access to Action Method
Applying Validation Attributes
Adding Simple Dependency Injection
Creating the Dependency Resolver
Using the Dependency Resolver in the Controller Class
Creating a Non-RESTful Web Service
Preparing the Routing Configuration
Defining the Web API Controller
Completing the Product Controller
Chapter 7: SportsStore: Creating the Clients
Setting Up JavaScript IntelliSense
Defining the Authentication Controller
Defining the Products Controller
Defining the Orders Controller
Creating the Customer Controller
Creating the Administration Client
Chapter 8: SportsStore: Deployment
Preparing the SportsStore Application
Preventing the Product Database from Resetting
Adding Database Connection Strings
Downloading the Publish Profile
Part 2: Results and Parameters
Chapter 9: The Anatomy of ASP.NET Web API
Understanding the Web API Namespaces and Types
Understanding the Web API Context Objects
Getting Information About the Request
Getting Information About the Controller
Getting Information About Everything Else
Understanding the Web API Components
Controllers, Actions, and Results
Chapter 10: Creating and Configuring a Web API Application
Creating the Model and Repository
Testing the Example Application
Configuring a Web API Application
Configuring Web API Through the ASP.NET Platform
Understanding the Configuration Object
Configuring Web API Dependency Injection
Preparing for Dependency Injection
Understanding the Web API Dependency Interfaces
Installing the Dependency Injection Container
Implementing the Dependency Interfaces
Configuring Dependency Injection for Web API and MVC
Installing the Dependency Injection Packages
Adding MVC Support to the Resolver
Chapter 11: Action Method Results
Understanding Action Method Results
Consuming a No Result Action Method
Understanding the IHttpActionResult Interface
Using the ApiController Action Result Methods
Creating a Custom Action Result
Understanding the Default Behavior
Understanding the Content Negotiation Process
Implementing a Custom Content Negotiator
Returning Negotiable Action Results
Creating Negotiable Action Results
Chapter 12: Creating Media Type Formatters
Creating a Media Type Formatter
Implementing a Basic Media Type Formatter
Setting the HTTP Response Headers
Participating in the Negotiation Process
Using the Mapping Extension Methods
Creating Per-Request Media Type Formatters
Creating the Formatter Instance
Testing the Per-Request Formatter
Chapter 13: Using the Built-in Media Formatters
Working with the Built-in Media Type Formatters
Listing the Built-in Media Type Formatters
Dealing with Type Matching During Negotiation
Working with the JSON Media Type Formatter
Configuring the JSON Media Type Formatter
Using the XML Media Type Formatter
Configuring the XML Media Type Formatter
Getting the Xml Media Type Formatter Working
Chapter 14: Understanding Parameter and Model Binding
Testing the Example Application
Understanding the Default Binding Behavior
Understanding Parameter Binding
Performing Binding Customizations
Binding Complex Types from the Request URL
Binding Simple Types from the Request Body
Manually Obtaining Request Values
Chapter 15: Binding Simple Data Types
Working with Value Providers and Value Provider Factories
Understanding Value Providers and Value Provider Factories
Creating a Custom Value Provider and Factory
Applying a Custom Value Provider and Factory
Understanding How Web API Looks for Values
Applying a Value Provider Factory with an Attribute
Extending the Default Behavior
Creating a Parameter Binding Rule
Chapter 16: Binding Complex Data Types Part I
Using the Built-in Model Binders
Broadening the Source of Binding Values
Binding Collections and Arrays
Working with Custom Model Binders
Creating a Custom Model Binder
Applying a Custom Model Binder
Chapter 17: Binding Complex Data Types Part II
Creating a Custom Media Type Formatter
Creating the Media Type Formatter
Registering and Testing the Media Type Formatter
Using the Built-in Media Type Formatters
Customizing the Model Binding Process
Changing the Behavior of the Default Action Value Binder
Creating a Custom Action Value Binder
Understanding Common Data Problems
Using Web API Model Validation
Removing the Debug Output Code
Using the Binding Control Attributes
Performing Validation with Validation Attributes
Using the Built-in Validation Attributes
Creating a Self-validating Model Class
Performing Validation in a Media Type Formatter
Creating a Validating Media Type Formatter
Registering and Using the Custom Media Type Formatter
Chapter 19: Dispatching Requests
Creating the Web API Web Service
Creating the MVC Controller and View
Testing the Example Application
Understanding Request Dispatching
Understanding the HttpServer Class
Understanding the HttpRoutingDispatcher Class
Understanding the HttpControllerDispatcher Class
Customizing the Dispatch Process
Creating Custom Message Handlers
Customizing Other Dispatch Components
Chapter 20: URL Routing: Part I
Testing the Application Changes
Understanding the Routing Classes and Interfaces
Working with Convention-Based Routing
Using Routing Data Default Values
Chapter 21: URL Routing: Part II
Creating a Controller-wide Direct Route
Using a Route-Specific Message Handler
Applying Custom Constraints to Direct Routes
Chapter 22: Controllers and Actions
Using Built-in Services and Features
Understanding the ApiController Dispatch Process
Preparing the Example Controller
Understanding the Action Selection Process
Understanding the RESTful/Non-RESTful Routing Problem
Understanding the Action Method Execution Process
Customizing the Controller Dispatch Process
Creating a Custom IHttpActionInvoker Implementation
Creating a Custom IHttpActionSelector Implementation
Creating a Controller-Specific Configuration
Creating an Action Filter by Implementing IActionFilter
Using the Convenience Action Filter Base Class
Creating a Short-Circuiting Action Filter
Understanding the Filter Pipeline
Displaying the Filter Pipeline
Working with Authentication Filters
Understanding Authentication Filters
Creating an Authentication Filter
Reviewing Filters in the Dispatch Process
Working with Authorization Filters
Understanding Authorization Filters
Creating an Authorization Filter
Appling the Authorization Filter
Removing the Authentication Filter
Using the Built-in Authorization Filter Attributes
Reworking the Authentication Filter
Working with Exception Filters
Understanding the Default Behavior
Understanding Exception Filters
Deriving the Filter from the ExceptionFilterAttribute Class
Overriding Built-in Filter Types
Relying on the Default Behavior
Using an Implementation of the IHttpActionResult Interface
Using an Error Response and an HttpError Object
Adding Extra Information to the HttpError Object
Including Model State Errors in the HTTP Response
Displaying HttpError Information in the Client
Creating a Self-hosted Web API Application
Creating the Model and Repository
Defining the Configuration Classes
Creating the Web API Controller
18.118.189.251