I've seen an answer to this here Greater Than or Equal To Today Date validation annotation in MVC3 and was attempting to use the Remote option suggested in my .Net Core 3.1 application. I have put a breakpoint in my action but it's never hitting it, just throwing the validation over and over again regardless of the date entered (or blank). Here's what I've tried:
As annotation on my data model:
[Remote("ValidateDateEqualOrGreater", "AccountViewer", HttpMethod="POST", ErrorMessage = "Date cannot be prior to today's date")]
public DateTimeOffset? PostDate {get; set; }
Inside my controller:
[HttpPost]
public JsonResult ValidateDateEqualOrGreater(DateTimeOffset Date)
{
if (Date == null || Date >= DateTimeOffset.UtcNow.Date)
{
return Json(true);
}
return Json(false);
}
It doesn't appear that the code is getting called at all, as I'm not hitting any of the breakpoints in it. What else do you have to do to get the Remote() annotation working?