ASP.NET WEB API: HTTP MESSAGE LIFECYLE ASP.NET Hosting

You can host Web API within an ASP.NET application, or inside your own process (self-hosting). After the initial entry point, the HTTP messages go through the same pipeline. The HTTP request message is first converted to an HttpRequestMessage object, which provides strongly typed access to the HTTP message.

ASP.NET 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 ASP.NET Web API at http://www.asp.net/web-api.

Self-Hosting

HttpControllerHandler

HttpSelfHostServer

HttpServer

A

Create Controller Create an API controller based on the request. 1. Select controller type HttpControllerDispatcher SelectController

HttpControllerDescriptor

IHttpControllerSelector GetControllerTypes

ICollection

IHttpControllerTypeResolver HttpRequestMessage

HttpResponseMessage

GetAssemblies

ICollection

IAssembliesResolver

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.

A message handler can create the response directly, skipping the rest of the pipeline.

DelegatingHandler

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.

Yes

HttpControllerDispatcher Create

Per-route Message Handlers

HttpRoutingDispatcher

Route.Handler is null?

2. Activate controller

IHttpControllerActivator

Route.Handler

No

IHttpController

DelegatingHandler

B

Select Controller Action Select an action based on the request.

A message handler can create the response directly, skipping the rest of the pipeline.

HttpControllerDispatcher HttpMessageHandler

Create API controller

A

ApiController

This message handler can invoke HttpControllerDispatcher and return to the “main” path, or provide a custom end point.

SelectAction

HttpActionDescriptor

IHttpActionSelector

Controller

B

The controller is where you define the main logic for handling an HTTP request. Your controller derives from the ApiController class or implements the IHttpController interface.

Select controller action E

Error response

If the request is not authorized, an authorization filter can create an error response and skip the rest of the pipeline.

Authorization Filters

Invoke controller action, using HttpActionContext for bindings and model state.

Exception Filters

C

D

Model Binding

Result Conversion

Invoke Controller Action

ApiController InvokeActionAsync

Task

IHttpActionInvoker Action filters are invoked twice, before and after the controller action.

Action Filters

OnActionExecuting

Key

OnActionExecuted Exception!

E

Unhandled exceptions are routed to exception filters.

Built-in Class Extensibility Point

Invoke Action

Note Request

Controller Action

Response

C

D

HttpRequestMessage

Model Binding

Result Conversion

Request message

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.

The return value from the action is converted to an HttpResponseMessage.

URI

HttpResponseMessage

Headers Entity-body

FormatterParameterBinding

ModelBinderParameterBinding

Media Type Formatter

HttpParameterBinding

IContentNegotiator 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.

If return type is HttpResponseMessage, pass through.

Media Type Formatter

Complex Type

IModelBinder

IValueProvider

Simple Type

Action parameters

Any Type

HttpResponseMessage

If return type is void, create response with status 204 (No Content).

For all other return types, a media-type formatter serializes the value and writes it to the message body.

void

Other types

Action return value

Email: [email protected] © 2012 Microsoft Corporation. All rights reserved.

Web API_Final

All rights reserved. ASP.NET WEB API: HTTP MESSAGE LIFECYLE. ASP.NET Hosting. HTTP Message Handlers. Controller. Model Binding. Controller Action.

599KB Sizes 4 Downloads 169 Views

Recommend Documents

pdf-1418\web-architecture-web-design-and-web-development ...
... the apps below to open or edit this item. pdf-1418\web-architecture-web-design-and-web-development-questions-and-answers-by-suresh-basandra.pdf.

Web Designing & Web Development Tutorial Series - Introduction ...
Page 4 of 12. Difference Difference between Static & Dynamic Websites. Pawan Mall's Production. Static Web. Page/Website. Dynamic Web. Page/Website.

Web Appendix
We again assume U(x)=x throughout, following Doyle. As in our paper and in. Bleichrodt, Rohde, and Wakker (2009; BRW henceforth), we write ln for the natural logarithm instead of Doyle's log. As in the main text, (T:F) denotes receiving $F>0 at time

Web Appendix
We again assume U(x)=x throughout, following Doyle. As in our paper and in. Bleichrodt, Rohde, and Wakker (2009; BRW henceforth), we write ln for the natural.

With the evolution from Web 1.0 to Web 3.0, web ...
With the introduction of social networking sites, blogs, forums, and wikis, it is ... Evolving further, websites such as Amazon.com and Yahoo provide features such as .... 10. The layers of information can be grouped into four levels of information.

XML Programming: Web Applications and Web ...
Listings 1 - 11 - using XML data with relational databases. • building ...... DTDs are good at design time, and they are useful as a concise description of a shared ...

XML Programming: Web Applications and Web ...
Listings 1 - 11 - a degree in Russian from an ivy league school in the United States. He has pub- ..... XML IS THE CENTRAL TECHNOLOGY of the Internet. When it first ...... All their contributions are online, together with an excellent. 74. Chapter ..

Web 2.0: The New Face of the Web
Web 2.0: The NeW Face oF The Web. 3. Introduction. This is one of a series of white ... Prior to 2001, web sites were relatively static, designed to push information to ... Blogging and social networking comprise the largest segment of growth, ...

Web architecture and components which enable internet and web ...
Retrying... Web architecture and components which enable internet and web functionality.pdf. Web architecture and components which enable internet and web ...

The Mobile Web in Developing Countries - World Wide Web Consortium
1. The Mobile Web in Developing Countries. Ravi Jain [email protected] ... The explosive growth of mobile phones and mobile voice services in developing countries has led .... competition, regulation and the attributes of the fixed network.

Web architecture and components which enable internet and web ...
Page 2 of 4. Components: Web servers: This is server that the web hosting services would use to host your website, giving you a set. space on a server they own that holds your website so people can view it. This allows the. use of web applications, a

web aarest.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. web aarest.pdf.

negative
Jun 3, 2016 - Oil near USD50/bbl but industry players not excited ... should disconnect oil services players' stock price with oil price as ..... Software Technology • Telcos ..... constituting legal, accounting or tax advice, and that for accurate

web based - GitHub
I am nota developer! Hello, I'm Emil Öberg,. I am not a developer. ... Page 6 ... iOS old. iOS 8. Android old. Android 5. PLZ give tab bar ...

Programming Mobile Web - GitHub
Wordpress. Theme. Plugin. Joomla. Theme. Add on. Drupal. Module. Theme. More … Forum. Vanilla. esoTalk. Phpbb. More … More … Web server. Apache.

web report.pdf
Our main priority will always be to reduce homelessness. in Dundee and support individuals on to independence. Page 3 of 3. web report.pdf. web report.pdf.

web arrest.pdf
objektif yang disediakan. www.myschoolchildren.com. Muat turun (percuma) kertas soalan lain di : Page 1 of 1. web arrest.pdf. web arrest.pdf. Open. Extract.

web appendix
This Web Appendix contains additional information and data analyses that could not be ... report a crime. Since we look at 40 years of crime data, it is impossible to correct reported crimes for the ..... Origin countries: Albania, Algeria, Banglades

Web Technologies.pdf
Inexpensive to open and close database connections for each client request. 9. Which of the following method is not central to the life cycle of a servlet? a. init( ).

Web application security frame
Feb 14, 2006 - tion environment to determine the application type, for example ... intelligence (AI) component that infers an action that a user ...... Files, paths,.