I have a controller that has a controller method looking like:
[Route("GetDashboard")]
[HttpPost("GetDashboard")]
public async Task<IActionResult> PostDashboard([FromBody]Period period)
{
Debug.WriteLine("PostDasboard in");
var eventTimer = new EventTimer();
var forDate = period.FromDate;
var q = GetMySales(new ReportFilterModel { FromDate = forDate.AddDays(-31), UntilDate = forDate });
eventTimer.NextEvent("PostDashboard");
var r = await (from i in q
group i by i.Order.Shift.Site into s
select new
{
id = s.Key.Key,
name = s.Key.Name,
days = from i in s
group i by i.Order.Shift.AltTrade into d
select new
{
date = d.Key.GetEpochTicks(),
total = d.Sum(i => i.Sell),
qty = d.Sum(i => i.Quantity)
}
}).ToListAsync();
eventTimer.NextEvent($"Got List: {r.Count()}");
var result = Json(r);
if (_timing || (eventTimer.Elapsed >= 5000)) // More than sec..
await _eventLogger.DebugAsync("Timing", eventTimer.Final, null);
Debug.WriteLine("PostDasboard Out");
return result;
}
I've added some bits to track the overall time. The method itself takes about 3 sec. After that it can take an additional 12 to 30 sec before the response finishes: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executed action OnlineUsers.Controllers.CloudTradeController.PostDashboard (OnlineUsers) in 35352.5891ms Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 35399.931ms 200 application/json; charset=utf-8};
About the only thing that is different for the delayed methods is nested Json. Does anybody have seen similar delays? are the any other tools available to get closer to where the delay is.