LTweb Tuan01
LTweb Tuan01
A. MUC TIEU
— Trinh bay duoc cau tric cua m6 hinh MVC
— [Link] MVC tao duoc ApplicationWeb theo m6 hinh nay.
— Thiét ké View — Control hién thi duoc cac thé html (...).
— LayoutTemplate, RenderBodyQ(), ActionLink
B. NOI DUNG THUC HANH
1. Co sé ly thuyét
1.1. Kién thire cin nho
Chuong 1. Téng quan vé lap trinh Web voi [Link] MVC
1.1. Téng quan vé lap trinh Web
Lap trinh Web la qua trinh xdy dung cac tng dung hoac trang web cé thé truy cap
thong qua Internet hoac mang noi b6. Ung dung Web hoat dong dia trén mo hinh Client
— Server, trong dé Client (thwong 1a trinh duyét hodc img dung di dong) giri yéu cau
(request) toi Server (may chu luwu trit va xtr ly img dung). Server tiép nhan, xt ly yéu
cau (bao g6m ca truy xuat dit liéu tir co so di liéu néu can) va gtri lai phan héi (response)
cho Client. M6 hinh nay gitp tach biét gitta phan hién thi (giao dién nguwoi ding) va
phan xtr ly dit liéu, tir d6 tang tinh linh hoat va kha nang mo réng cua hé thong.
1.1.1. M6 hinh Client — Server
e Client: Thiét bi hodc phan mém (trinh duyét, tmg dung) gui yéu cau (request)
dén may cht.
e Server: May chu tiép nhan yéu cau, xtr ly va gtri lai phan hdi (response).
Request
ee a
_ =
=
HTML
Browser Web Server
Request —
Client Controller
Response
App_Data Luu tri cac tap tin dir ligu, tap tin XML hoac
Database
App_Start Chia cac tap tin lién quan dén viéc cau hinh cho
cac tinh nang : routers, filters,...
Content Chita tap tin CSS, hinh anh lién quan dén giao
dién
[Link]
Yéu cau:
1. Tao 01 controller Home ( [Link])
2. Thiét ké View Index nhu sau
Home Page x
Cc a @ localhost:1737
€ Cc @ localhost:1737
5. Sau do thuc hién diéu hung trang sang view About trong Controller Home.
6. Tao chuyén hung giita 2 trang Index va About (str dung hyperlink).
7. Tao mot phuong thirc HienThi trong HomeController thue hign tra vé chudi lay tir
tham so id nhw sau:
lecalhest:1737/Home/Indev? x ] is
os Cc a 2) localhost Home, 7
ID=-@
8. Tao mot phuong thirc Index3() trong HomeController thuc hién tra vé View
[Link]; thyc hién truyén tham 2 s6 id va name lay tir URL, sau do xuat gia
tri 2 tham s6 nay trén view [Link] nhu sau (Ding ViewData va Dung
ViewB at)
Index3 - My [Link] Application 6% Mail - Nguyén Hai Yén - Outlo’ X New Tab |
Application name
Index3
ID=9
Name = Nguyen
Hai Yen;
Hwong dan:
B1: Tao Project mdi File > New > Project..
Create a new
project BORIS TORRE AES: UK? i Clear all
Ga : Console Application G# = ce
Console App (.NET Framework)
A project for creating a command-line application
C# Windows Library
Next
Khoa Céng nghé thong tin BAI THUC HANH 1
BO mén Ky thuat phan mém Tong quan vé Lap trinh Web
LAP TRINH WEB
LTWeb_Bai01
Location
CADuLieu\, 2025-2026_HK1\LapTrinhWeb\, -|
Solution name @
Framework
Back Create
| Web Forms
A project template for creating [Link] Web Forms applications. [Link] Web Forms lets you build dynamic websites
using a familiar drag-and-drop, event-driven model. A design surface and hundreds of controls and components let Add folders & core references
you rapidly build sophisticated, powerful Ul-driven sites with data access.
[a] Web Forms
4 mvc
Level mvc [7] Web API
A project template for creating [Link] MVC applications. [Link] MVC allows you to build applications using the
Model-View- Controller architecture. [Link] MVC includes many features that enable fast, test-driven development
for creating applications that use the latest standards.
tf Advanced
ri Web API
[¥] Configure for HTTPS
A project template for creating RESTful HTTP services that can reach a broad range of clients including browsers and
mobile devices. CJ Docker support
ese Bail_HelloWord
t
i public class RouteConfig
t
A public static void RegisterRoutes(RouteCollection routes)
{
routes. IgnoreRoute("{resource}.axd/{*pathInfo}");
routes .MapRoute(
name: "Default",
url: “{controller}/{action}/{id}",
| defaults: new { controller = "Home", action = "About", id = [Link] }
3
t
, t
Ket qua:
RK ? e
Home Page x
C a @ localhost:1737
Yéu cau:
(1) Tao giao dién [Link] nhu sau:
© DB localhost:64493/Product/Index# © (70% “OW
LAN HO BIEP
HOA CUCI
QUATANG
TRAI CAY
250,000d - 400.0004
400,000d - 600,0004
600,000d - 900,000d
Trén 1,000,0000
[Link]
Di ién thoai: 024.73007.008 - 093.4647.172 Dién thoai: 028.73007.008 - 094.7723.444
Di ia chi: S6 63/445 Lac Long Quan, Tay H6, Ha Dia chi: 189 XVN Tinh, P.17, Q. Binh Thanh
ORE Noi Email: hom@[Link]
Email: hn@[Link]
LAN HO IEP
HOA CUGI
Sinh nhat 1 Sinh nhat 2 Sinh nhat 3 Sinh nhat 4
Gia: 300,000 Gia: 600,000 Gia: 500,000d Gia: 700,000 HOA LAN
QUA TANG
TRAI CAY
250,000¢ - 400,000¢
Cudi 1 Cuéi 2 cuéi 3 Ccusi 4
400,000d - 600,000d
Gia: 300,000 Gia: 600,000 Gia: 500,000 Gia: 700,000
600,0004 - 900,000¢
Trén 1,000,0004
SPE ers
ONE MEL Mana rease4)
HOA LAN
El
TRAI CAY
Giao vién
fo Bisson)
250,000d - 400,000
400,000d - 600,000
600,0004 - 900,0004
Trén 1,000,000
Q dD localhost:64493 70%
Ha Néi: TP.Hé Chi Minh:
[Link]
Dién thoai: 024.73007.008 - 093.4647.172 Dién thoai: 028.73007.008 - 094.7723.444
Bia chi: $6 63/445 Lac Long Quan, Tay Hé, Ha Dia chi: 189 XVN Tinh, P.17, Q. Binh Thanh
a Ndi Email: hcm @[Link]
Email: hn@[Link]
HOA LAN
[_JRemember Password
HOA CHIA BUON
QUA TANG
TRAI CAY
250,000d - 400,000d
400,000d - 600,000d
600,000d - 900,0004
Trén 1,000,000d
Yéu cau: o
Su dung giao dién chung (layout) khi thiét ké phan khung trang
May xép
May che
May vom
-_
May xép
May vom
Hé tro tructuyén —_
Submit
Mat khau
Ngay sinh
Ngay v
O Nam © N&
Dang ky
May xép
May che
May vom
Yéu cau:
— Tao Folder Shared trong Views dé luu cac giao dién mau (Master page);
Add moi mot giao dién mau
@® localhost-41229/#
10