im in the process of writing ASP.NET Core REST API. here is controller method and this method should get selected when incoming route was matched.
controller.cs
[HttpGet]
[Route("/api/Account/{accountID}/{productIds}/files")]
public ActionResult<IEnumerable<FilesDto>> GetFiles(long accountID, string productIds)
{
using (new MethodCallLogger(logger, UserContext))
{
return Ok(FilesService.GetFiles(accountID, productIds));
}
}
FilesService.cs
public IEnumerable<FilesDto> GetFiles(long accountID, string productIds)
{
// in some cases productIds will come empty
if(!string.isNullorEmpty(productIds)
{
}
}
in some cases productIds will come empty, to select all the products.
if i pass null or empty string from FrontEnd Reactjs, here its receiving "null" or "undefined" as string value. so the string.isNullorEmpty condition get passed and throwing error, like invalid produtIDs.
so, what is the perfect to handle this "null" or "undefined". or how can we pass empty string or null from reactjs to backend.
Thanks for your time.