I wanted to share how I worked through using DateTime parameters in my .NET Core MVC Controllers. I used this to create a date range filter capability in my solution.
Incorrect
[HttpGet, Route("dateRange/{start}/{end}")] public IActionResult Get(DateTime start, DateTime end) { //invalid values (e.g. /bogus/52) get converted to a valid DateTime value of 1/1/0001 00:00:00.001 if (start != DateTime.MinValue && end != DateTime.MinValue) { if (start < end) { return Json(_Repo.GetByDateRange(start, end)); } } return BadRequest("Invalid Date Range"); }