public async void OnActionExecuted(ActionExecutedContext context) { _stopwatch.Stop(); var elapsed = _stopwatch.Elapsed.ToString(); string responseBody = ""; if (context.Result != null) { var result = (ObjectResult)context.Result; responseBody = JsonSerializer.Serialize(result.Value); } _actionLogModel.Response = responseBody; _actionLogModel.ResponseCode = context.HttpContext.Response.StatusCode.ToString(); _actionLogModel.HttpStatusCode = context.HttpContext.Response.StatusCode; _actionLogModel.RespondedAt = DateTime.Now; _actionLogModel.ResponseTime = elapsed; _elasticsearchService.InsertActionLog(_actionLogModel); }