How to validate if a parameter is null in asp .net core 2.1. In the below example the "IsValid" returns true.
This is the code we use
[HttpGet]
[Route("/api/test")]
public async Task<IActionResult> test([BindRequired, FromQuery]string id)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
return Ok();
}
TestUrl I use: testurl/api/test and Still ModelState.IsValid returns true