The difference between return object and return ok(object) is i think pre-defined way to telling the status we are going to return in response to a webapi call.
return Ok(response) : In Below Block of Code webapi is returning OK(Response) that gives products list with OK that means Status of api call is predined with HTTP Status CODE 200. In case of any Error. There are many other return types like Unauthorized( ), Bad Request( ), NotFound() etc that defines the return type we are returning from webapi. In these cases In case of any Exception you need to handle it using exception handling or other method and pass the return type using other return types like badrequest or unauthorized
[HttpGet("{id}")]
public IActionResult Get(int id)
{
if(id==0)
return BadRequest();
var response = _products.Single(x => x.Id == id);
return Ok(response);
}
return response : In Below Block of code we are not using return Ok (Object) here we are not defining any response type for webapi endpoint in this case result will be same but you will have less control on HTTP Status code and error response. Here is WEB API will decide the HTTP status code or response code to return depending on result / exception. you need to define the response code to return
[HttpGet("{id}")]
public Productsmodel Get(int id)
{
var response = _products.Single(x => x.Id == id);
return response;
}