0

Everything is ok but after auth process the _humans list not changing. The last one must add token into list array.

my list array

public List<Human> _humans = new List<Human>
{
  new Human ( 1,"test","false","asd" )
};

-- non working method:

[HttpGet]
public async Task<IActionResult> register( Human employee)
{
  ....
  await HttpContext.SignInAsync(principles);

  humans.Add(new Human(22,"ASDDD","AAS",employee.token));

  return RedirectToAction("Index","Home");
}
ColmanJ
  • 457
  • 2
  • 12
  • 28
barron
  • 103
  • 1
  • 9

1 Answers1

0

As stated in this answer a new controller instance will be constructed for each request. So for each request a new list will be created and everything added to it will be lost at the end of the request.

To persist your data you should serialize it to a database or file. You could also make the list static but then the data will still be lost when the application restarts.

ColmanJ
  • 457
  • 2
  • 12
  • 28