Tại sao Json Request Behaviorcần thiết?
Nếu tôi muốn hạn chế HttpGet yêu cầu đối với hành động của mình, tôi có thể trang trí hành động bằng [HttpPost]thuộc tính
Thí dụ:
[HttpPost]
public JsonResult Foo()
{
return Json("Secrets");
}
// Instead of:
public JsonResult Foo()
{
return Json("Secrets", JsonRequestBehavior.AllowGet);
}
Tại sao không [HttpPost]đủ?
Tại sao khuôn khổ "lỗi" chúng tôi với JsonRequestBehavior.AllowGetmọi JsonResultthứ chúng tôi có. Nếu tôi muốn từ chối nhận yêu cầu, tôi sẽ thêm HttpPostthuộc tính.