I read this announcement
https://github.com/aspnet/Announcements/issues/153
HttpBadRequest is now BadRequest
but I can't find a BadRequest method and what happened to this.Ok(Object) method?
Regarding Bad Requests
As mentioned in this related GitHub issue comment, you would actually create a new instance of a BadRequestResult() object :
public IActionResult Index()
{
return new BadRequestResult();
}
Regarding Ok() Requests
As far as the Ok()method goes, it actually comes from the controller itself, so it should still work as you might expect :
public IActionResult Index()
{
return this.Ok(yourObject);
}
However, there is also an OkResult() and OkObjectResult(), which can return an OK request and one that accepts an object overload as well :
public IActionResult Index()
{
return new OkResult();
}
public IActionResult Index()
{
return new OkObjectResult(yourObject);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With