asp.net - What is the complete lifecycle of an OData controller http request in WebApi 2 -


i wonder full lifecycle of odata http request on odatacontroller hosted in iis.

for instance:

  • what iis pipelining steps ?
  • how request handled when entering asp.net controllers area ?
  • when routing applied ?
  • when attributes such httppost, applyfilter applied ?

maybe thread can you: the asp.net web api 2 http message lifecycle in 43 easy steps

it starts iis: enter image description here

  1. iis (or owin self-hosting) receives request.
  2. the request passed instance of httpserver. enter image description here

  3. httpserver responsible dispatching httprequestmessage objects.

  4. httprequestmessage provides strongly-typed access request. enter image description here

  5. if 1 or more global instances of delegatinghandler exist on pipeline, request passed it. request arrives @ instances of delegatinghandler in order said instances added pipeline.

delegatinghandler instances can skip remainder of pipeline , create own response. in custom validation fluentvalidation post.

  1. if httprequestmessage passes delegatinghandler instances (or no such handler exists), request proceeds httproutingdispatcher instance.

httproutingdispatcher chooses routing handler call based on matching route. if no such route exists (e.g. route.handler null, seen in diagram) request proceeds directly step 10. enter image description here

  1. if route handler exists given route, httprequestmessage sent handler.
  2. it possible have instances of delegatinghandler attached individual routes. if such handlers exist, request goes them (in order added pipeline).
  3. an instance of httpmessagehandler handles request. if provide custom httpmessagehandler, said handler can optionally return request "main" path or custom end point. enter image description here
  4. the request received instance of httpcontrollerdispatcher, route request appropriate route determined request's url. enter image description here
  5. the httpcontrollerdispatcher selects appropriate controller route request to.
  6. an instance of ihttpcontrollerselector selects appropriate httpcontrollerdescriptor given httpmessage.
  7. the ihttpcontrollerselector calls instance of ihttpcontrollertyperesolver, call...
  8. an instance of iassembliesresolver, selects appropriate controller , returns httpcontrollerdispatcher step 11. note: if implement dependency injection, iassembliesresolver replaced whatever container register.
  9. once httpcontrollerdispatcher has reference appropriate controller, calls create() method on ihttpcontrolleractivator...
  10. which creates actual controller , returns dispatcher. dispatcher sends request select controller action routine, shown below. enter image description here enter image description here
  11. we have instance of apicontroller represents actual controller class request routed to. said instance calls selectaction() method on ihttpactionselector...
  12. which returns instance of httpactiondescriptor representing action needs called. enter image description here
  13. once pipeline has determined action route request to, executes authentication filters inserted pipeline (either globally or local invoked action). these filters allow authenticate requests either individual actions, entire controllers, or globally throughout application. filters exist executed in order added pipeline (global filters first, controller-level filters, action-level filters).
  14. the request proceeds [authorization filters] layer, authorization filters exist applied request. authorization filters can optionally create own response , send back, rather allowing request proceed through pipeline. these filters applied in same manner authentication filters (globally, controller-level, action-level). note authorization filters can used on request, not response, assumed if response exists, user had authorization generate it.
  15. the request enters model binding process, shown in next part of main poster. each parameter needed action can bound value 1 of 3 separate paths. path binding system uses depends on value needed exists within request. enter image description here
  16. if data needed action parameter value exists in entity body, web api reads body of request; instance of formatterparameterbinding invoke appropriate formatter classes...
  17. which bind values media type (using mediatypeformatter)...
  18. which results in new complex type.
  19. if data needed parameter value exists in url or query string, said url passed instance of imodelbinder, uses ivalueprovider map values model (see phil haack's post topic more info)....
  20. which results in simple type.
  21. if custom httpparameterbinding exists, system uses custom binding build value...
  22. which results in kind (simple or complex) of object being mappable (see mike stall's wonderful series on topic). enter image description here
  23. now request bound model, passed through action filters may exist in pipeline (either globally or action being invoked).
  24. once action filters passed, action invoked, , system waits response it. enter image description here
  25. if action produces exception , exception filter exists, exception filter receives , processes exception.
  26. if no exception occurred, action produces instance of httpresponsemessage running result conversion subroutine, shown in next screenshot. enter image description here
  27. if return type httpresponsemessage, don't need conversion, pass return on through.
  28. if return type void, .net return httpresponsemessage status 204 no content.
  29. if return type ihttpactionresult, call method executeasync create httpresponsemessage. in web api method in use return ok(); or return badrequest(); or similar, return statement follows process, rather of other processes, since return type of actions ihttpactionresult.
  30. for other types, .net create httpresponsemessage , place serialized value of return in body of message.
  31. once httpresponsemessage has been created, return main pipeline. enter image description here
  32. pass newly-created httpresponsemessage through authenticationfilters may exist. enter image description here
  33. the httpresponsemessage flows through httpcontrollerdispatcher, @ point won't it.
  34. the response flows through httproutingdispatcher, again won't it.
  35. the response proceeds through delegatinghandlers set handle it. @ point, delegatinghandler objects can change response being sent (e.g. intercept responses , change appropriate http status). enter image description here
  36. the final httpresponsemessage given httpserver instance.
  37. which returns http response invoking client

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -