// Handler chạy khi truy cập trang bằng phương thức get public IActionResult OnGet(int id) { int?ID = null; if (Request.RouteValues["id"] != null) { ID = Int32.Parse(Request.RouteValues["id"].ToString()); product = ProductContext.FindProductByID(ID.Value); if (product == null) { // Khônng thấy chuyển hướng về trang /product/ return(RedirectToPage("ViewProduct", new { id = "" })); } } // Trả về kết quả trang Razor return(Page()); }