Take advantage of MVC model binding when passing data to a controller.
[HttpGet]
public IActionResult Index(DateTime birthday)
{
List<Person> people = _context.Persons.Where(p => p.Birthday == birthday).ToList();
return Ok(people);
}
The model.
public class Person
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public DateTime Birthday { get; set; }
}
The URL is simply.
https://localhost:7141/person/?birthday=1/1/2022
The example I provided is a GET but a post works exactly the same way. See any MVC tutorial and the model binding documentation.
ASP.NET Core MVC with EF Core - tutorial series
Model Binding in ASP.NET Core
Lastly, when asking for assistance please post enough code to reproduce the actual issue. There could be other issues with your approach that we cannot see.