Web API revised2 - Microsoft
WEB API 2: HTTP MESSAGE LIFECYLE
You can host Web API inside IIS or inside your own process (self-hosting).
The HTTP request message is first converted to an HttpRequestMessage object, which provides strongly typed access to the HTTP message.
IIS Hosting
OWIN Self-Hosting
HTTP Request
HTTP Response
HttpServer
Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. It is an ideal platform for building RESTful applications on the .NET Framework.
This poster shows how an HTTP request flows through the Web API pipeline, and how the HTTP response flows back. The diagram also shows extensibility points, where you can add custom code or even replace the default behavior entirely. You can find documentation and tutorials for Web API at .
HttpRequestMessage
HttpResponseMessage
HTTP Message Handlers
HTTP message handlers are the first stage in the processing pipeline. They process HTTP request messages on the way in, and HTTP response messages on the way out. To create a custom message handler, derive from the DelegatingHandler class. You can add multiple message handlers. Message handlers can be global or assigned to a specific route. A per-route message handler is invoked only when the request matches that route. Per-route message handlers are configured in the routing table.
A message handler can create the response directly, skipping the rest of the pipeline.
DelegatingHandler
HttpRoutingDispatcher Route.Handler is null?
Yes
A message handler can create the response directly, skipping the rest of the pipeline.
Per-route Message Handlers
Route.Handler
No DelegatingHandler
HttpControllerDispatcher
A Create API controller
HttpMessageHandler
Controller
The controller is where you define the main logic for handling an HTTP request. Your controller derives from the ApiController class.
B Select controller action
Authentication Filters
AuthenticateAsync
ChallengeAsync
If the request is not authorized, an authorization filter can create an error response and skip the rest of the pipeline.
Authorization Filters
Error response
Exception Filters
C
D
Model Binding
Result Conversion
Action filters are invoked twice, before and after the controller action.
Action Filters
OnActionExecuting
OnActionExecuted Exception!
Unhandled exceptions are routed to exception filters.
E Invoke Action
This message handler can invoke HttpControllerDispatcher and return to the "main" path, or provide a custom end point.
Controller Action
A Create Controller Create an API controller based on the request.
1. Select controller type
HttpControllerDispatcher
SelectController
HttpControllerDescriptor
IHttpControllerSelector
GetControllerTypes
ICollection
IHttpControllerTypeResolver
GetAssemblies
ICollection
IAssembliesResolver
2. Activate controller HttpControllerDispatcher
Create
IHttpController
IHttpControllerActivator
B Select Controller Action Select an action based on the request.
ApiController
SelectAction
HttpActionDescriptor
IHttpActionSelector
E Invoke Controller Action
Invoke controller action, using HttpActionContext for bindings and model state.
ApiController
InvokeActionAsync
Task
IHttpActionInvoker
Key
Built-in Class Extensibility Point Note Request Response
C
Model Binding
Model binding uses the request to create values for the parameters of the action. These values are passed to the action when the action is invoked.
HttpRequestMessage
Request message URI Headers Entity-body
FormatterParameterBinding
ModelBinderParameterBinding
HttpParameterBinding
A media-type formatter reads the message body (if any).
The default model binders read from the URI path and query string.
A custom parameter binding can read any part of the HTTP request.
Media Type Formatter
IModelBinder IValueProvider
Complex Type
Simple Type Action parameters
Any Type
D
Result Conversion
The return value from the action is converted to an HttpResponseMessage.
HttpResponseMessage
Media Type Formatter IContentNegotiator
If return type is HttpResponseMessage, pass through.
If return type is void, create response with status 204 (No Content).
If return type is IHttpActionResult, call ExecuteAync to create an HttpResponseMessage
For all other return types, a media-type formatter serializes the value and writes it to the message body.
HttpResponseMessage
void
IHttpActionResult
Other types
Action return value
Email: MSPoster@ ? 2014 Microsoft Corporation. All rights reserved.
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- web services basics iit bombay
- building apis with django and django rest framework read the docs
- selenium tutorial for beginners step by step with examples
- rest in a nutshell a mini guide for python developers
- beginner s guide to tls ssl certificates digicert
- restful web services
- javascript front end web app tutorial part 1 web engineering
- overview of amazon web services aws whitepaper
- core web api best practices microsoft
- 7 — web api design
Related searches
- microsoft web apps download
- microsoft office free web apps
- web based microsoft word
- narrator for web pages microsoft edge
- microsoft api download
- microsoft unified communication api 4 0
- microsoft speech api 4 0
- microsoft unified communications api 4 0
- microsoft unified communications managed api 4 0
- microsoft word api reference
- python client web api interactive brokers
- web api documentation tool