简体   繁体   English

需要在 web Api2 项目中获取请求和响应正文和头部。我该怎么做?

[英]Need to get request and response body and head in web Api2 project .How can i do it?

Web Api2项目,,,Controller继承自另一个控制器,,,,需要获取json格式的每个请求和响应的body和head

try to intercept the request using the DelegatingHanler something like the following尝试使用DelegatingHanler拦截请求,如下所示

public class IntercepterMessageHandler : DelegatingHandler
{
    protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
    {
            //try to manipulate the request object

        return base.SendAsync(request, cancellationToken);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从Web api2中的请求获取远程用户名 - how can i get remote user name from request in web api2 如何在ASP.NET Web API2中自定义响应 - How to custom response in asp.net web api2 使用Web API2上传文件作为正文的一部分 - upload a file as part of the Body with Web API2 如何在Web API2控制器中放置多个GET方法? - How to put multiple GET methods in Web API2 controller? 如何将参数传递给Web API2 - How to pass parameters to web api2 Web API2,如何返回错误 - Web API2 ,How to return an error 如何使用 .net 4 api 端点从 Request.Content 对象获取原始请求正文 - How do I get the raw request body from the Request.Content object using .net 4 api endpoint 如何从 ASP.NET Web API ValueProvider 中的 HTTP POST 请求检索正文值? - How do I retrieve body values from an HTTP POST request in an ASP.NET Web API ValueProvider? 如何在 ASP.NET Core 5 Web API 中绑定来自请求主体的简单类型 - How can I bind simple type coming from body of the request in ASP.NET Core 5 Web API 使用Owin Self-Host ASP.Net API2无法接收带有正文中的数据而非查询字符串的POST请求 - Using Owin Self-Host ASP.Net API2 Can't Receive POST Request with data in body instead of query string
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM