I have an ASP.Net MVC project where I generate a report that requires a lot of the machine's processing feature.
I have a Action
that generates and another that returns the report data in an Object List, so I thought that by creating a static variable, I could save the data in the report and return it as needed.
private static List<MeuObjeto> DadosRelatorio = new List<MeuObjeto>();
public ActionResult MinhaAction ()
{
// Limpando dados que já estavam.
if (DadosRelatorio.Count() > 0)
{
DadosRelatorio.Clear();
}
...
// Preenchendo DadosRelatorio
...
}
public ActionResult OutraAction ()
{
return Json(DadosRelatorio, JsonRequestBehavior.AllowGet);
}
The problem is that when 2 or more users simultaneously generate a report, the data in one overwrites another.
I thought that when creating a static variable the framework itself would manage a variable for each on the server, but that is not the case, the same variable is for every user.
Is there an alternative?