I'm trying to return HTTP codes that would contain a custom message outside of a controller.
For example, in a controller I can have
return BadRequest("Invalid");
Inside a regular method I tried the following code
return Microsoft.AspNetCore.Http.StatusCodes.Status400BadRequest("Invalid");
But I get the following message
"Non-invocable 'StatusCodes.Status400BadRequest' cannot be used like a method"
Is there anyway I can return HTTP codes with custom messages outside of a controller?
Microsoft.AspNetCore.Http.StatusCodes.Status400BadRequestis a const int, not a function. You can't thus invoke it with(and).