asp.net core filter response object record

Baidu to read the stream is substantially the response.body. After the recording is over and then, the flow index reset, so that too much trouble.


In fact, asp.net core team must have taken into account this need, such as records request response log. In response to the kind of data filtering.

In OnActionExecuted of ActionExecutedContext which has a result. In debug mode, you can see the Result inconsistent with the response object is different objects

 
if (context.Result is JsonResult)
                {
                    var value = ((JsonResult)context.Result).Value;
                }
                if (context.Result is ObjectResult)
                {
                    var value = ((ObjectResult)context.Result).Value;
                }
 

Direct access to their own needs can return the object, then do the deal ok.

Guess you like

Origin www.cnblogs.com/boxrice/p/11670592.html