HTTP Message Handlers in ASP.NET Web API
2021-06-19 07:06
标签:cell nbsp gets mat ade err gdi orm control https://docs.microsoft.com/en-us/aspnet/web-api/overview/advanced/http-message-handlers A message handler is a class that receives an HTTP request and returns an HTTP response. Message handlers derive from the abstract HttpMessageHandler class. Typically, a series of message handlers are chained together. The first handler receives an HTTP request, does some processing, and gives the request to the next handler. At some point, the response is created and goes back up the chain. This pattern is called a delegating handler. On the server side, the Web API pipeline uses some built-in message handlers: You can add custom handlers to the pipeline. Message handlers are good for cross-cutting concerns that operate at the level of HTTP messages (rather than controller actions). For example, a message handler might: This diagram shows two custom handlers inserted into the pipeline: Note:On the client side, HttpClient also uses message handlers. For more information, see HttpClient Message Handlers. To write a custom message handler, derive from System.Net.Http.DelegatingHandler and override the SendAsync method. This method has the following signature: The method takes an HttpRequestMessage as input and asynchronously returns an HttpResponseMessage. A typical implementation does the following: Here is a trivial example: HTTP Message Handlers in ASP.NET Web API 标签:cell nbsp gets mat ade err gdi orm control 原文地址:https://www.cnblogs.com/chucklu/p/10289181.htmlServer-Side Message Handlers
Custom Message Handlers
Task
base.SendAsync
to send the request to the inner handler.
文章标题:HTTP Message Handlers in ASP.NET Web API
文章链接:http://soscw.com/essay/95849.html