Contents

About the Authors

About the Technical Reviewer

Acknowledgments

Introduction

images Chapter 1: Introduction to ASP.NET Web API

ASP.NET Web API

The Basics

ASP.NET Web API Libraries

ASP.NET Web API Source Code

ASP.NET Web API Background

HTTP

SOAP

Web Services Extensions

WCF

Rage Against the SOAP: HTTP Makes a Comeback

WCF REST

webHttpBinding in WCF

WCF Web APIs

Birth of ASP.NET Web API

ASP.NET Web API Architecture

Architectural Features

ASP.NET Web API Elements

HTTP Processing Pipeline

ASP.NET Web API in Modern Architecture

Public API

Middleware and Internal API

Modern Web Application API

Cloud Services

Services for Native Apps

Self-Hosted HTTP Server

ASP.NET Web API and Other Architectural Aspects

ASP.NET Web API and ASP.NET MVC

ASP.NET Web API and DDD

ASP.NET Web API and CQRS

ASP.NET Web API and Transactions

ASP.NET Web API and API Governance

Provide Top-Notch Documentation

Publish Schemas

Plan Your Versioning Strategy

Provide Test Services, Logging, and Tracing Facilities for Consumers

Heavily Instrument, Benchmark, and Monitor Your API

Avoid Publishing Client Libraries if You Can

Summary

images Chapter 2: Introduction to Asynchronous Programming in .NET

What Is It All About?

IIS Web Server and Asynchronous Processing

IIS Web Server Processing Architecture in a Nutshell

IIS and Server Configuration for High Concurrency

Where to Favor Asynchronous Programming

Old Asynchronous Programming Models in .NET

Asynchronous Programming Model (APM)

Event-based Asynchronous Pattern (EAP)

Task-Based Asynchronous Pattern (TAP)

Continuations, Errors, and Task Status

Composition

TaskCompletionSource<TResult>

Cancellation

Linked Cancellation Tokens

C# 5.0 Asynchronous Language Features

Exception Handling

SynchronizationContext

Summary

images Chapter 3: HTTP, REST, and Hypermedia

HTTP Basics

Resources and URIs

HTTP Methods

HTTP Status Codes

HTTP in Action

HTTP Header Fields

Internet Media Types

REST

Service Oriented Architectures and HTTP

Shifting to a RESTful Architecture

REST in Theory

Richardson Maturity Model

Summary

images Chapter 4: HttpClient

Commonalities: HTTP in ASP.NET Web API and HttpClient

HttpRequestMessage

HttpResponseMessage

HttpContent

HttpClient

Introducing HttpClient

Getting Data Using HttpClient

Sending Data Using HttpClient

Using ASP.NET Forms Authentication from HttpClient

Summary

images Chapter 5: Sample Application: Application Structure and Domain Model

PingYourPackage: An Overview

Application Features and Domain Language

Project Structure and Architecture

Architecture

Project Structure

Building the Domain Model

Brief Introduction to Entity Framework

Building Entity Objects and DbContext

Working with the Repository Pattern

Creating the Service Layer

Summary

images Chapter 6: Sample Application: Building the Web API

Infrastructure of Our Web API Application

Creating Routes

Initial Configuration

Registering Dependencies

Implementing the Security

Implementing the Message Handler for Forcing HTTPS

Implementing the Message Handler for Basic Authentication

AuthorizeAttribute

Implementing Controllers

PingYourPackage.API.Model Project

Implementing the ShipmentsController

Implementing the AffiliateShipmentsController

Summary

images Chapter 7: Sample Application: Building the Wrapper and Web Client

Building a .NET Wrapper for the HTTP API

PingYourPackage.API.Client Project

Integrating with WebApiDoodle.Net.Http.Client NuGet Package

Creating the ShipmentsClient and ShipmentTypesClient

Creating the ApiClientContext

Building a Web Client with ASP.NET MVC

PingYourPackage.API.Client.Web Project

Registering the Client Classes Through an IoC Container

Implementing the MVC Controller

Summary

images Chapter 8: Routing

Understanding Routing Mechanism

Defining Web API Routes

HTTP Methods and Routing

Having Multiple Web API Routes

Route Defaults

Optional Parameters

Route Constraints

Summary

images Chapter 9: Controllers and Actions

Overview

Overview of HttpRoutingDispatcher

Controller Type Selection

Creating a Controller

IHttpController Interface and Your Own Controller

ApiControllers: Out of the Box IHttpController Implementation

Controller Actions

Action Selection

Return Values

Per-Controller-Type Configuration

Summary

images Chapter 10: Message Handlers

Overview and Message Handler Mechanism

HttpMessageHandler

DelegatingHandler Class

Message Handlers and the Russian Doll Model

Custom Message Handlers

MethodOverrideHandler

CustomResponseHeaderHandler

EmptyPostBodyMessageHandler

Registering Custom Message Handlers

Per-Route Message Handlers

Summary

images Chapter 11: Filters

Overview and Filter Processing Model

Use Cases

Default Filter Implementations

Filter Execution Order

Registering Filters

Action and Controller-Based Filters

Global Filters

Types of Filters

Action Filters

Authorization Filters

Exception Filters

Summary

images Chapter 12: Media Type Formatters and Model Binding

Overview

Formatter Processing Model

Content Negotiation Algorithm

Media Type Formatters

Default Formatters

JsonMediaTypeFormatter

XMLMediaTypeFormatter

FormUrlEncodedMediaTypeFormatter

JQueryMvcFormUrlEncodedFormatter

BufferedMediaTypeFormatter

Custom Formatters

JsonpMediaTypeFormatter

CSVMediaTypeFormatter

Formatter Configuration

Modifying Existing Formatters

Registering a New Formatter

Removing a Formatter

Changing the Formatter Order

Media Type Mappings

Involving Content Negotiation with MediaTypeMapping

Default Media Type Mappings

A Custom Media Type Mapping: RouteDataMapping

Model Binding

Model Binder Mechanism

Default Model Binder

Customizing Model Binding

Summary

images Chapter 13: Input Validation

Overview

How Validation Works Through Parameter Binding

Model State

Data Annotation Validation Attributes

RequiredAttribute

StringLengthAttribute

RangeAttribute

RegularExpressionAttribute

EmailAddressAttribute

MaxLengthAttribute and MinLengthAttribute

Custom Validation

Creating Custom Validation Attributes

IValidatableObject Custom Validation

Summary

images Chapter 14: Dependency Resolution

Key Inversion of Control Concepts

Inversion of Control (IoC)

Dependency Injection

Service Locator

Factory Pattern

Registration and Lifetime Scope in Dependency Injection

Service Location in ASP.NET Web API

Dependency Resolution Model in ASP.NET Web API

A Typical Dependency Resolution Scenario

Understanding the Lifetime of the IDependencyResolver and IDependencyScope

IDependencyScope and HttpRequestMessage

Using DependencyResolver Implementations Available for ASP.NET Web API

Implementing DependencyResolver Model in DI Frameworks

Implementing DependencyResolver for AutoFac

Implementing DependencyResolver for Castle Windsor

Implementing DependencyResolver for Unity

Implementing DependencyResolver for NInject

Summary

images Chapter 15: Unit Testing and Integration Testing

Unit Testing in ASP.NET Web API

Testing Frameworks

Sample Application

Testing Controllers

Testing Routes

Testing Delegating Handlers (Message Handlers)

Testing Filters

Integration Testing

Integration Testing and Automation

Integration Testing and BDD

Integration Testing in ASP.NET Web API

Summary

images Chapter 16: Optimization and Performance

ASP.NET Web API Asynchronous Actions

Scenarios and Use Cases

HTTP Caching

HTTP Specification for Caching

Applying HTTP Caching in ASP.NET Web API

Summary

images Chapter 17: Hosting

Hypertext Transfer Protocol Stack

HTTP.SYS Queuing

HTTP.SYS Caching

ASP.NET Web API Hosting Model

HttpConfiguration

HttpServer

Web Hosting

Runtime Configuration

Runtime Execution

Hosting PingYourPackage Sample

Self-Hosting

Runtime Configuration

Runtime Execution

Self-Hosting Example Scenarios

OWIN

Why Should I Learn About OWIN?

OWIN Concepts and Runtime

Example: Web Hosting ASP.NET Web API in OWIN

Future of OWIN

Summary

images Chapter 18: Tracing, Logging, and API Documentation

Tracing and Logging

The Tracing Mechanisms in ASP.NET Web API

ITraceWriter

ITraceWrite Implementation Using NLog

Using ITraceWriter in User Code

Documenting Your Web API

The Cars API

Documenting an HTTP API by Hand

Documenting an HTTP API Using ApiExplorer

Summary

Index

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.163.229