When a user provides invalid data in a request body, which HTTP status code is most appropriate to return?
4 phương ánCó giải thích
Các phương án trả lời
Chọn một phương ánLời giảiChọn phương án để mở
Khi người dùng cung cấp dữ liệu không hợp lệ trong cơ thể yêu cầu, trạng thái HTTP phù hợp nhất để trả về là trạng thái lỗi yêu cầu không hợp lệ. Điều này xảy ra khi máy chủ nhận được yêu cầu nhưng không thể xử lý do dữ liệu không hợp lệ. Trạng thái lỗi này cho biết yêu cầu không hợp lệ và yêu cầu người dùng cung cấp dữ liệu hợp lệ. Ví dụ, khi người dùng nhập sai địa chỉ email hoặc mật khẩu, trạng thái lỗi này sẽ được trả về.
Cùng chương 4
A controller action needs to return a "Not Found" response when a resource does not exist. Which of the following is the best way to achieve this? [HttpGet("{id}")] public ActionResult<Product> GetProduct(int id) { var product = _productService.GetById(id); if (product == null) { return ???; // What should be here? } return product; }Câu hỏiAccording to inference rules, any complex type parameter NOT registered in the DI container and NOT matching a route parameter will be inferred as coming from where?Có lời giảiCâu hỏiBy default, where does the model binder attempt to get the data for a complex type parameter (like a class or record) in an [ApiController] action?Có lời giảiCâu hỏiCả 19 câu của chủ đề19 câu