Professional Documents
Culture Documents
Chu de 2 - Controllers
Chu de 2 - Controllers
CONTROLLERS
- Chứa các phương thức Actions cho project (file .cs).
Ví dụ: AccountController.cs, HelloworldController.cs.
- Tất cả các file .cs đều phải kết thúc bởi chuỗi Controller.
- Tất cả các controller chứa trong thư mục Controllers
1
Action:
2
Action
3
4
Action
5
Action
6
7
Action
8
Action
9
Ví dụ
10
Ví dụ
11
Ví dụ
12
13
Action IO: Truyền/Nhận tham số Input/Output
14
15
Sử dụng Request:
16
Ví dụ sau sẽ nhận tham số và lưu dữ liệu vào ViewBag:
17
Sử dụng FormCollection:
- Tập hợp các tham số của Form vào đối số của FormCollection của
Action, chỉ nhận được các trường Form.
- Ví dụ, nhận tham số của các trường Form và
: lưu vào ViewBag:
18
Sử dụng Action Arguments:
19
Sử dụng Model:
20