Actions trong ASP.NET MVC là gì?
Actions trong ASP.NET MVC là gì?
Action là phương thức public của Controller xử lý một request và trả về kết quả (ActionResult).
public class OrdersController : Controller
{
public ActionResult Index() => View(repo.All()); // GET /Orders
[HttpGet] public ActionResult Details(int id) => View(repo.Get(id)); // GET /Orders/Details/5
[HttpPost, ValidateAntiForgeryToken]
public ActionResult Create(Order o) { if (!ModelState.IsValid) return View(o); repo.Add(o); return RedirectToAction("Index"); }
Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.