HttpContext.Current
is null
because your task is executed on a pool thread without AspNetSynchronizationContext
synchronization context.
Use TaskScheduler.FromCurrentSynchronizationContext()
:
Task.Factory.StartNew(() =>
{
AsyncManager.Parameters["dataPlot"] =
highChartModel.GetGraphPlotPointsNew(fromDate, toDate, item);
AsyncManager.OutstandingOperations.Decrement();
},
CancellationToken.None,
TaskCreationOptions.None,
TaskScheduler.FromCurrentSynchronizationContext());