Trung BìnhC# iconC#

`IActionResult` và `ActionResult<T>` khác nhau như thế nào?

IActionResult là interface cho tất cả action return types. ActionResult là implementation non-generic. ActionResult<T> cho phép trả về cả typed response thành công lẫn error results.

  • Các implementation phổ biến: OkObjectResult (200), NotFoundResult (404), BadRequestResult (400), CreatedAtActionResult (201).
  • Dùng ActionResult<T> trong Web API để đặc tả rõ kiểu trả về.

Xem toàn bộ C# cùng filter theo level & chủ đề con.

Mở danh sách C#