简体   繁体   中英

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM