如果我有一个带有 UsersController 的 API,其中包含获取用户列表的方法,那么我应该返回一个空集合还是NotFound("Could not get the list of the users")在找不到用户时返回一个集合?
NotFound("Could not get the list of the users")
我读过很多关于返回空列表或 null 的内容,大多数答案都说我应该返回预期的内容。如果需要一个列表,则应返回一个空列表而不是 null。
但这是否也意味着 Web API 呢?
c# asp.net-web-api asp.net-core-webapi
asp.net-core-webapi ×1
asp.net-web-api ×1
c# ×1