Nhung nhing website nay Itti yeu eau ngubi xiy dung va von luinh phai ce kiln thirc tot vi cite ngen ngtt trinh web nhu HTML, Php, ASP.NET de dim bao ne duqc host Ong thong sulk.. Chinh
Trang 1BO MAO DUC VA DAO TAO TRUtING DAI HQC THANG LONG
antalana
TIMMS LONG VOitvilVITT
KHOA LUAN TOT NGHIEP
St' DVNG ASP.NET MVC 4
Giio Ain hudng din : ThS Trin Quang Dny Sinh vien thyt hien : NO Quang Hang - A17110 Chnyen nginh : Khoa luic may tinh
Trang 2Leif NOI DAU
Su ra did edit Internet di mang den nhieu cc hOi di nit ngin tang each gills mai ngtred tren Min the gi6i Ton dung co hOi ma Internet mang lai, nhau ca Stith va toe chbc d8 cho ra dbi nhieu trang web de kit nei mci ngubi lwi v6i nhau, Ara mang Lai nhieu tier ich ham cho ngubi sir dung Nhung nhing website nay Itti yeu eau ngubi xiy dung va von luinh phai ce kiln thirc tot vi cite ngen ngtt trinh web nhu HTML, Php, ASP.NET de dim bao ne duqc host Ong thong sulk
Chinh au bat den va hsn chi de di lam nay sinh ra mOt nhu ceu cen mOt phin mim c6 the gfilp viec xay dung va v5n hanh met website ter non don gian voi mai ngubi, Ice ca nhttng ngubi c6 kiln thirc hsn chi hoLic kitting c6 kiln thirc ye cite nem
net ltip trinh web Chinh nhttng nhu ceu d61i nin tang de cho ra did "He quan tri nOi dung", no da mang lai nhang thig' den trong viec xiy dung va hash mOt website cho tit a mai ngubi
VI nhttng tien ich to tan cis nd mang lsi, nen em di chan di tai "Xiy dtmg quan tri nOi dung sir dung ASP.NET MVC4" nhim muc (Itch dm hi& khai thac va img dung cite tru diem cda he quan tri nOi dung vita cuOc song
NOi dung bao cao duqc chia lam 5 chuung chinh:
Chiming 1 Ting (wan vi asp.net mvc framework
Chuang nay giCri thieu ye m8 hInh MVC, ASP.NET Framework cing nhu cat thinh pan cc ban cis ASP.NET Framework
Chuang 2 Ting plan vi hf (pin tri nil dung
Chuang nay neu len djnh nghla ve He quin trj nOi dung, cite d#c diem
ca bim ming nhu phan lotti cite he quan tri nOi dung
Chung 3 Phin tich thilt ki hf thing
Chuang nay bao gem cite gith down edit phen phan tich nhu: Bac tat you ciu, phen tich thiet ke CSDL, thiet Ice chirc ring
Chiang 4 /ay dgng chit alit
Chuang nay di via viec xiy dung cu the Ulm; chive Wing curt he th6ng theo m6 hinh MVC bao gam cac: Model, View , Controller
Chuang 5 Triin khal *ng dyng
Chuang nay hubng din each xult ban vi trim khai mOt irng dung ASP.NET MVC
Trang 3Mac du di co ging holm thien di ti>i khea luon v6i tit a no Ivc dm ban than nhung chic chin killing thieu khei nhung thieu sot ICinh mong qut thay tan tinh chi bao
Met lan nits, em xin chart thinh cam an va luta mong duqc sq dung gop
qu ty bau ciia tit ca mqi nguiri de em co the den be hon ICinh chew qut thay co luen luon m?nh khOe, gat Mi duqc nhieu thanh tong trong su nghiep
Ha Noi, ngtly 4 titling 12 neim 2014 Sinh vien thvc hifn
Ngt; Quang Hang
Trang 4MVC LVC
CHUONG 1 TONG QUAN VE ASP.NET MVC FRAMEWORK 9
1.4.2 C.& Marsh plain w ban ciao ASP.NET MVC 13 1.4.3 Qui: trinh hoot (long ctia mot sing thmg ASP.NET MVC 14 1.4.4 Mc5t tinh ndng ndi b4t mia ASP.NET MVC Framework 16
1.4.7 So sash glut: ASP.NET webform vii ASP.NET MVC 17 1.4.8 Khbi too mdi sing dyng ASP.NET MVC Framework 18
CHIMING 2 TONG QUAN VE IIE QUAN Tilt NQI DUNG 28
2.2 Tel eao Ini an bf quill tri n(11 dung 28 2.3 Cie ale dilm co, bin aim hf quin trj nid dung 29
Trang 53.1.6 Quoin lY tai khodn 39
Trang 65.3 Chu hinh HS cho Framework MVC at dung microsoft web platform
Trang 7DANH MVC CAC THU4T NGU VA Tit VIET TAT
Trang 8DANH MVC HINH ANH
Binh 1.4 Cac thank philn ca ban aria ASPNET MVC 13
Binh 1.8 Minh hpa mat Solution Explorer cia ASP.NET MVC3 20 Hinh 1.9 Giao dien ca ban khi chgy thing dim ASP.NET MVC có san 22 Binh 1.10 Kit nit ca so' dit lieu bang Entity Framework - buck 1 23 Rink 1.11 Kit nth ca so at lieu being Entity Framework - bark 2 23 Binh 1.12 Kit nit ca sa dit lieu bang Entity Framework - bit& 3 24 Binh 1.13 Kit nit ca sa dit lieu bang Entity Framework - but 4 25 Binh 1.14 Kit not ca so' du lieu bang Entity Framework - but 5 26 Binh 1.15 Kit nil cc sa die lieu bang Entity Framework - buoy 6 27
Rink 3.10 Giao dien mink hpa chac ndng quan lf) thong tin ca nhtin 49 Rink 3.11 Giao dien mink hpa char ndng IBy lgi mat khau 50
Trang 9Minh 116 Giao dien xem kit qua 52 Binh 3.17 Giao din chic ndng hien thi dank sack bill Wit 53 Minh 3.18 Giao din chic ?Ong them mdri bid wit 54 Minh 3.19 Giao di& chair ndng kiln thi dank sack chuyen MIX 54 Minh 3.20 Giao din chic ndng them mai chuyin muc 55 Minh 3.21 Giao dien cluic nong Turin ly binh lu4n 55 HIM 3.22 Giao diets dank sack cau hdi khdo sat 55
Minh 5.2 Man hinh lua chon platform di cai djit 79 Minh 5.3 Man hinh kilm tra cal dal NET Framework va ASP.NET 80
Rink 5.5 Internet Information Services (IIS) Manager 81
Trang 10CHUCING 1 TONG QUAN Vit ASENET MVC FRAMEWORK
1.1 Giii thien vi m8 klub MVC
Khi cic phin mini img dung ngiy sing phit Wien ion munh vi da clang thi van thiet ke kitn true cho phin mem cling tit non phut tap hon Nhftng ling dung web gib day cling di phit trier den mOt tim cao m6i, ching khan con la nhitng wag dung web thong thuimg vei chi= Wing hien thj th8ng tin ma la nhting h¢ thong thong tin h8 trq nhttng tang web tucmg tic veri ngtrin ding Nhieu giai phap thiet ke kien trim he thong dirge dim ra veri muc dich lam cho he thong linh hoot, mem deo, di phit then vi tin tai lau dii Trong de, giii pluip thiet ke theo m8 hinh lden frac MVC duqc Trygve Reenskaug de xuat vao nhOng nam 70 cia the 14 , 20 t6 ra ret hieu quit
M8 hinh MVC (Model - View - Controller) la mOt 'den trite phin mem hay m8 hlnh thiet Ice dirge sir dung trong kg thu$t phin mem N6 giup cho cac nha phat then tich 1mg dung cis hg ra thanh 3 phin kbac nhau Model, View vi Controller M8i thanh phin c6 mOt nhiem vp rieng biet vi dOc lip vOl cac thanh phin Ichac
Cdc thank phin cola MVC
Trang 11T6ng (wan vi ASP.NET MVC framework
1.1.2 Hoyt ding cola me binh MVC
Day la met catch don gib de m6 ti lei luting sv kien duqc xti lt trong MVC:
- User ttrcrng tic yen View, bing cich click vim button, user ph yeu ciu di
- Controller nh$n vi dieu Wang chtIng den dimg phuong thirc xu It 6 Model
- Model nhan thong tin Ws thvc thi cic yeu ciu
- !Chi Model ban tet viec xir lt, View se nhan ket qui riY Model Ara hien th1 lai cho ngutri dung
Rink 1.2 Quy trinh haat &Ong ctia mO hinh MVC
1.1.3 Un Mn vi nhuprm cola MVC
tin aim:
The hien tinh chuyen nghiep trong lap trinh, pass tich thiet ke Do duce chia think tic think phis dec lap nen gitip ph& then Ung dvng shank, don Wan, de sang ctip, bito tri
Trang 12Tang quan vi ASP.NET MVC framework
Nhugc diem:
Dal WA du an nhe viec itp dung ma hinh MVC gay ding kink, ten thbi gian trong qui trinh ph& then Ten thai gian thing chuyin de lieu curt cfc thrInh phin 1.2 GM thifu vP ASP.NET
ASP.NET let mOt nen tang phit tan Ong dung web (web application framework)
duqc pith then va cung cep boi Microsoft, cho phep nhftng ngutri hip trinh to ra nhftng trang web Ong, nhftng ting dung web vit nhftng djch vu web Lim diu tien duqc due m thi frac:mg vio thang 2 nom 2002 con yeti phien bin 1.0 clue NET framework, la ding nghe n6i tiap mkt Microsoft Active Server Pages(ASP) ASP.NET dugc bien djch dual dung Common Language Runtime (CLR), cho phep nhitng ngutri Hip trinh viet mil ASP.NET veri bit lcSr ng8n net nao duct h6 trg lx!ri NET language 1.3 ASP.NET WebForm troyin tb6ng
ASP.NET la mOt buerc nhity vqt khi lin diu suit hien, nhim thu hgp khoang cach gitta plat tan Window Form hueng dei tucong (c6 tang thai) va phat then web htrOng HTML (kong trang thii) Hinh duel day minh hqa Ong nghe ASP.NET Webform
ASP.NET Web Forms
Ansel INCOMPNIONSOMPIAIMOrallt0 s statstid, objectailidall persavring model
Hinh 1.3 Gong nghe ASP.NET WebForm
Vei Web Forms, Microsoft di c6 an di um vi HTML bang crich m8 pheng giao then ngtrai clang nhu 18 mOt d6i tucmg dieu khien (Control) co au trac hoot dOng phis Server
M61 doi tutyng dieu khien (Control) then dei tang thai cos no thong qua cic you
au (sir dung tfnh tiling ViewState), bieu then bang cat ml HTML khi can thief Ngotli
ra, no con tit dOng kit noSi cat sv lden phis Client (nhu su kien barn button) tai cat su lden phia Server duqc xir ljr tuang ling Thgc ti, Web Forms lit mOt lap 1riru Wing
Trang 13Tong quan vi ASP.NET MVC framework
•6 Nbbng diim bon chi eta ASP.NET Web Forms
—ASP.NET Web Forms troy& th6ng thing la mOt y Wong At tot, nhung thuc ti loi phit sink nhttng then phirc top khic Theo thin gian, viec sir dung ASP.NET Web Forms di neu b$t len met sti thieu set;
—ViewState: Co chi duy tri tong thii thong qua cic yeu citu (request) Omen mang lei ket qui li nhftng kh6i luqng len dtt lieu duqc chuyen giao gbh client
vi server Dtt lieu thy c6 the len den hang tram Kbs 6 mot ting dung web via phii, vi n6 di qua lid yeti bit IcS, yeu cau nio Dieu nay lim chom di then gian
chb phin h6i vi lam tang nhu au bang thong cria server,
—Page life cycle (Chu kjf din toi ctia mOt trang web): Li co the kit DM su kien phis client yeti mil xis ljr su kien phis server N6 phirc top vi de bi phi vat;
— thirc sai ve viec tech biet cic thknh phan: MO With code-behind cos ASP.NET cung clip mOt giii phip cho phep Ong (burg dua code ra khoi cic dens HTML vio thinh mOt lap code-behind rieng biet Dieu nay duqc hoan nghenh rang rai yen viec tech biet giao dien veri mil xis ly Nhung thuc te, nhttng nhb phit trier duqc khuyen lchich pha trOn ml giao dien vei m1 it* ljr img dung (thy lit xis 1S, CSDL) trong nhOng 16p code-behind khong 16 Neu Wrong c6 su tech biet gitta cic thinh pliltn, ket qui cu6i cang c6 the rat kh6 hie%
—Limited control over HTML (giei hun kiem soit HTML): Server control to too
ra cic ma HTML, nhung kh8ng phii la ma HTML ma to mong dqi Ngobi viec
mi HTML ctia Chung thubng khOng tub theo lieu chuin web hoitc kh8ng sir
dung tdt CSS ma he th6ng cic server control con too ra cic gii tri ID phirc top
vi khong doin truck duqc, lam kh6 khin trong viec s* dung JavaScript;
—Kha fling kiem th* tb1p: Cic nhi thiet ke cue ASP.NET kh8ng the du doin ring kiim this to dOng se tit thinh mot phin tat yeu cue xu huemg phit then philn mem Kheng ngoc nhien khi kien trtic chitt the ma hp thiet ke la khang pith hqp vol viec Lich hqp Idem du)
ASP.NET vin tip Arc phit Ink Phien bin 2.0 them mOt thanh phin chuiln de giim bet s6 lucing code ma Chung to can phii to viet Vol phien bin gin nhit ASP.NET 4.5, mqi this di duqc ning clip ding ke Phien ban ASP.NET 4.5 di ip dung mOt s6 filth riling cue ASP.NET MVC vbo Web Forms Tuy v(iy, yin con mOt hon chi ton tai ben tong n6
Trang 14Tang plan vi ASP.NET MVC framework
1.4 ASP.NET MVC Framework
Nhu dl glen thieu b phin twat, m8 hinh MVC voi tru diem coa minh dit dirge (mg dung tong mOt s6 cac framework Trong do pith ki den ASP.NET MVC, mOt framework ml ngu6n me mei, idly dung ten ASP.NET
ASP.NET MVC Framework duqc thuc thi ten m8 hlnh model—view—controller (MVC) NO gqn nhy, di ding him phin giao then, tich hqp cac tinh fling cM ASP.NET MVC Framework duqc djnh nghia tong namespace System.Web.Mvc vi
11 met phin ctla lchong gian ten System.Web
1.42 Ngulin gic
Tuy dog nghe ASP.NET MVC mei duct phit then nhung ne c6 lich sit liu Nan ding MVC duct ph& minh beci Trygve Renskaug, 6ng di viet trang gity Mu lien nen vi MVC veo nitm 1978 Ban diu n6 duqc goi 11 Thing Model View Editor pattern, nhung sau d6 n6 duqc dit ten lyi 11 Model View Controller pattern
ASP.NET MVC lan du lien =it hien de 11 trong du an ma ngu6n mb
MonoRail
Ngu8n g6c th$t su de cho ra dbi tong nghe Microsoft ASP.NET MVC li do Scott Guthrie (mOt tong nhing nhe sang tao ra ASP.NET) ten chuyen bay din Austin, Texas de nOi vi heti thito A1t.NET vio tang 10-2007
Phien ban ASP.NET MVC 1.0 duqc ra dtri vio nlim 2009
1.4.2 Cdc thinh Rhin co' bin cola ASP.NET MVC
ASP.NET MVC Framework
Hinh 1.4 Cdc thank pluin co be cites ASP.NET MVC
Models: Cat d6i aging Models la mOt phin colt img dung, cac dai Wong nay thiet lap logic ctla phan de lieu cult (mg dung Thong thutmg, cac ddi Wong model lay
vi luu tang thai cM model tong CSDL Vi du nhu, met deli tucmg Product (sin
Trang 15Tong quan ve ASP.NET MVC framework
pham) se lay de lieu CSDL, thao tic ten de lieu vit se cep nhtit de lieu ter lai vio bang Products b SQL Server
Views: Views li cic thinh pal dung de hien thj giao dien ngubi dung (UI) Th8ng thubng, view duqc to don vio th8ng tin de lieu Models Vi do nhu, view dung
de cOp Slit bang Products se hien thi cic hOp yin bin, drop-down list, vi cac check box doa Iran trang thli hien tai cua met d6i tuqng Product
Controllers: Controller 11 cic thhnh phin dOng de quill lt Wong tic ngubi dung, lam viec vei model vi chip view de hien thi giao dien ngubi dung Trong mat *rig dung MVC, view chi duqc clang de hien thj thong tin, controller chju Mich nhiem quail ljr vi dip tri ned dung do ngubi thing nh$p vi tucmg tic yen ngubi dung Vi du, controller se quail ljt cic de lieu ngubi clang gal len (query-string values) va gel cic gia tri de den model, model se lily det lieu to CSDL nhtr yap cac gii tri nay
M8 hinh MVC giap chfing ta Mo duqc cac ling dung ma chung phis tich inch it cic kith onh cos ling dung (logic ye nh$p lieu, logic xfr 1ST tic vu vi logic ve giao dien) M8 hinh MVC chi ra m5i loci logic ki tren nen dupe thief) Ilp a dill tren ling dung Logic giao dien (UI logic) thuOc vi views Logic nh$p lieu (input logic) thuOc
ye controller Vi logic tic vu (Business logic — hi logic xi) It th8ng tin, moc dick chinh
cua (mg dung) thueic vi model Sr phin chia nay glop chung ta giiun bet dugs so pink tap cfm ling dung vi chi t#p trung vacs m8i lchia cen dupe chi det 6 meSi thtri diem
Vi du nhu chfing ta chi cin t$p trung vio giao dien (views) mi Wing phid quan tam den logic xfr ly thong tin ala Ong dung
So pit tich rash red ba thhnh phiin mkt (mg dung MVC con glop cho viec 1#p trinh dign ra song song VI do nhu mat trinh vien lam viec vei view, lap trinh vier the haii lo chi dat logic aia controller vi 1#p trinh vier thir ba c6 the tip trung vio logic tic vo cos model tai ding mat thoi diem
/.43 Que binh hop: Ong cda nit tong dpag ASP.NET MVC
Cie giai &on thoc hien cos met ling dung ASP.NET MVC dirge trinh bay du& day:
—Nh#n yeu diu diu tien: Trong file Global.asax, cic del tugng Route dirge them vac) RouteTable;
—Thut hien viec djnh tuyen: Module Ur1RoutingTable sir dung dei tugng Route diu tien thich hqp trong RouteTable de to d6i tugng RouteData D6i tugng nay sau d6 tao ra d6i tuqng RequestContext (IHttpContext);
—To ra trinh xt) ly yeu clu ling dung: D6i Wong MvcRouteHandler to ra mat the hien mitt 16p MvcHandler vi truyen vio n6 the hien RequestContext;
Trang 16I Ting quan vi ASP.NET MVC framework
—Tao ra controller Cie d6i tuqng MvcHandler sir dung the hien cult RequestContext de xIc djnh Ai tuong IcontrollerFactory qua do to ra the hien controller;
—Thvc hien vai fro cut% controller The hien MvcHandler pi phuang thirc Execute at controller;
—GO action method: D6i ttrqng ControllerActionInvoker se 'tic djnh action method cOa met 16p controller de pi ra
Trang 17Tang quan vi ASENET MVC framework
1.4.4 Mk sI fink nag nil bitt cda ASP.NET MVC Framework
- Tich bach cic tic vu curt img dung
- C6 kith rang ma rQng (extensible) & khi tiling nhung (pluggable) Cic thknh phen cia ASP.NET MVC duct thiet ke de chting co the duqc they the hoic thy chinh mOt cich a ding
- ASP.NET MVC c6 thknh phin inh xa URL manh me, cho phep ching to xiy dung nhitng ung dung co cat dja chi URL )(tic tich vi d6 tim hem Cic dja chi URL lcheng can phii c6 phin ma ring cis ten t(tp tin vi dirqc thiet ke di hi trq catiu djnh dung ten phi hqp yeti viec t6i uu hos tim kiem (URL)
- H5 trq catinh Wing ce sin curt ASP.NET nhu ca the xic flaw ngubi ding, quart 19 thknh vien, quyen, output caching vi data caching, seession vi profile, quip 19 tinh tang img dung, he thong ceu hinh
- Tu ASP.NET MVC 3 c6n be sung mOt view engine mei li Razor View Engine cho phep thiet lip cic view nhanh Chong, di ding vi ten ft tong sirc ham so v6i viec su dung Web Forms View Engine
1.4.5 11n aim
- D6 ding quin 19 su phtic tap cis ung dung bang each chic (mg dung that'll ba thknh pan model, view, controller
- H6 trq tot han cho In6 hinh phit thin ung dung huang kiem thin
- Hi thong djnh thy& mph me
- H6 trq tot cho catmg dung duct )(ay ckmg bbi nhttng dOi co nhieu trhth vien vi thiet ke mi yin quitn 19 &my tinh tiling mkt ung dung
- H6 trq nhitng tinh ming tot shit da c6 b ASP.NET
Trang 18Tang plan va ASP.NET MVC framework
1.4 7 So sdnh gifts ASP.NET webform vd ASP.NET MVC
Hinh 1.5 ASP.NET WebForm vci ASP.NET MVC
.Net Framework: ha trq img dung nhu desktop, web vi cic Ong dung console
ASP.NET framework la mOt phin Gila NET framework, dupe thy dung nhAm ha trq
cic img dung Web (caching, authentication vh authorization)
Trong do, Microsoft co 2 huong ph& then web tren nen ASP.NET la ASP.NET
Webforms vi ASP.NET MVC Muc dich m dbi ala ASP.NET MVC chi 11 sir day dal
ye met to duy, n6 !thong hoar Wan duly the cho c6 img dung ASP.NET Web Forms,
vi viec chon huang rho a thy dung mOt website lh dry thuOc vio cac nhil phat trier
Sr khic biet eta 2 huOng phit trien nay duqc the hien dual bang sau
Kier titc chuong
Cu phi', chuong trinh Sir dung cu phip ciia
webform, tat cac sir kien Nth controls do server quim
It
Clic sir kien duqc &ill khien NM
controllers, cac controls khAng
do server quan 1S,
Truy cep de lieu Su dung hiu het etc ding
nghe truy cep de lieu trong img dung
Phan Ion dung LINQ to SQL class de to m6 hinh truy cep depi tircmg
Debug Debug chuong trinh phid
thuc hien tat ca bao gem
cac lop truy cep de lieu,
Debug c6 the se dung cac unit test kiem tm et phucrng thirc trong controller
Trang 19A slut far aweing an mita:co wkw
ASPNET PAK 4 NSW& API
ASPIC Spay Web '.0- -
MANET Web Finns Aplacalion
ASST AWL I WS Appkalien
WILT Swot OS SOS WS SOWS
AWAIT MAX Saws USW WIC MAX San Caul ESA
WIC See Cameral
Tang quan va ASP.NET MVC framework
str hien thj, dieu khien citc controls/
T6c dO pit tai Tee del chom khi trong
trang c6 qui nhieu clic controls vi ViewState qui len
Phan tai nhanh him
Tuang tic yea
javascript
KM kh6 khan Thujn lqi
URL Address Ciu tnic dja chi URL ce
dim <filename>
.aspx?&<citc them 86>
Ciu tit dja chi dal mach theo clang Controllers/Action/ID
Klgri tno mOt drag dung MVC
Tmng bO phin mIm Visual Studio 2010 di c6 sin ASP.NET MVC Framework, to to mat di; an mei theo Qat:mg den sau: File > New Project > Visual C# > Web > ASP.NET MVC Web Application
Trang 20Tang quan in ASP.NET MVC framework
Minh 1.6 Kidd tgo zing dm ASP.NET MVC
Sau khi Sim OK, hOp thosi New ASP.NET MVC3 hien ra
Binh 1.7 H6p thogi New ASP.NET MVC3
Chung to cifi the chon kieu template a Empty, Internet Application hoec Intranet Application
- Empty se trio m nhang thu muc vi trip tin tei thin u cho ling dung MVC3
- Internet Application se trio ra met ling clung co sti tang mac dinh, chting to co the soma dei va xily dung ten n6
- Thy chip Intranet Application cling tuung tit nhu Internet Application, nhung duqc ceu hill sin de sir dung tong mei tnerng ruic thuc ngtroi thing thong qua ba tang Domain/ Active Directory
Trang 21Search Solution Explore (Ctrl.;) Solution 1 1.4eApplication1 1 (1 project)
Tang quan vB ASP.NET MVC framework
Chang ta cOng c6 the tao project test cling voi {mg dung MVC tfr cling met ctla se Ben canh d6, ta cling c6 the chip chi de ViewEngine 11 ASPX hoec Razor
6 day, ta chin Internet Application, Razor ViewEngine vi khOng chon unit test project Bain OK de holm tat
Solution Explorer se hien ra nhtr sau:
iii Fries Images
P lja Models
0 la Scripts tfr Vievs
0 a Globalmax
Q Web.config
Rinh 1.8 Minh hpa tn‘it Solution Explorer the ASP.NET MVC3
Bing clued day me ti nOi dung dyeing din curt met du in MVC Internet Application Dueng din M8 ti
/App_Data Luu tut dO lieu ctia ling dung Chung ta c6 the them met
CSDL SQL Ado thu muc nity
/Content Li thu muc thubng chtia nhttng de lieu tInh, nhu 11 hInh
anh, tep tin css,
Visual Web Developer tq dOng them thu muc Themes vio trong Content Thu muc themes la thu muc chi/a clic tep Jquery vi hInh anh Trong du an nay to c6 the x6a thu mix themes
Trang 22Ting quan vi ASP.NET MVC framework
Visual Web Developer cling them 1 file CSS chair vho du
an ten li Site.css tong thu muc Content File CSS li file de stia khi ta mu6n thay 651 style Gila ling dung
/Controllers Chfra clic 16p controller ctS chine nting nhen cac yeu ciu et
nguOi dung vi phan hid lgi
MVC yeu cAu ten curt tat ca cac file controller kit thiic bing chit "Controller"
/Models G5m cac lop de china cac m6 hinh &Si Wog CCM Ong
dung Models quart 15, vi thao tfic vei de lieu
Mews Lem tee the file HTML lien quan tei viec hien thi cos ling
dting (giao Bien Mien &nip-
Thu muc Views chfra tuang Ong m6i thu muc cho met controller
Mac djnh trong thu muc View c6 1 thu muc Shared dung
de chia se tai nguyen gigs cite controller
/Scripts Thu muc Script luu tee cac file Java Script curt Ong dung
Mac djnh Visual Web Developer se dat thu muc nay lim chuin di chfra cite file Jquery File "modernize lit file Javascript de h6 trq HTML5 vi CSS3
Bien dick on chay
WA viec lua chon Internet Application truec de, Ong dung curt chting ta di c6 du chfrc 'tang ca bin Chung ta chay the bang each bim F5 vi kit qui nhu sau
Trang 23• •• ^111141100114M•”•••••••SplistmilWriolealaiinflesankonselbeetraas_rmMI
Ons••••••••••••••01••••••••••641allatiraapasillowoaowsta iftlaytaloratese,
toNiallSoinlielmholbsIS
•(11•111111•11pdarsailImpilininiel
Aple••••••inlus 0•11111•100 SS MINI WIS
es wan mblegamovisawsiblipswilaatiat vow Strealla
T6ng quan vl ASP.NET MVC framework
mosom
6 111 L 0 kallornw • t®O I
a)C"." " MIN.Onhaft- itan•• On CI eels* WY 11€101••• II Om • gim• ••• •••10 • allY1=01•••
InIN 1*
Horne Abnur Conran
Home Page r-i-(t th < ternolatr tz - 4} rn C P NET 11/44VC aopliCatiOn,
IIinh 1.9 Giao dien ca ban khi chgy sing Ming ASP.NET MVC có scan
De dUng chuang trinh, ta t6 him phim Shift + F5 hoic chop Debug Menu vi chun Stop Debugging
KEt noi co' sir du, 114u SQL Server bang Entity Framework
ADO.NET Entity Framework li melt nen fling duct sir dung de lim tee vei CSDL Chung ta c6 the troy vin, than tic vol database giin tip thong qua ctic doi tinyng lip trinh
Chung ta se kit ngi CSDL bing Entity Framework Database First N6 se AT dOng too
ra data model va cic lop cho chin ta tir melt CSDL c6 sin Day li melt tech flip gin ph6 bien vl n6 thuc hien don Oki, nhanh ch6ng
Trong cite s6 Solution click chuOt phhi chun Add > New Item
Trang 24tod with, codes (sx0)
Tang quan vi ASP.NET MVC framework
• esumprma•obc — ~Amy ueaa •01111PJAVIA
A.t Vs in Bores (Coc Coc Browser) OrkSARA./
Browse Vdtb 1
Convents:VS Application
'1 ChedcAogsibily— lic ActionResult About()
Hinh 1.10 Kit nil ca sir dl? lieu blIng Entity Framework - bit& 1
Tiep theo, chip ADO.NET Entity Data Model, bim Add
▪ 500 Love GADD 44 LDS Mame
▪ 9:IUDs Mime
DAL Ft IMADame
• 1611 Fie
KS Or Veal CA Yowl CS Dwal CA DNS C•
VAS Or DRS Or Val a
bps Deal CA
A reject Dm kr °Wei a MONET Frey On Mt
Madellaina
Hinh 1.11 Kit ndi ca sew dft lieu bting Entity Framework - Mak 2
Giao dies hien m nhu ben duel, bim Next
return View();
Trang 25Tang plan vi ASP.NET MVC framework
Hinh 1.12 Kit noel co xi di? lieu bhng Entity Framework - buck 3
ant s6 mei hien ra, to chun New Connection vi toy chon clic thong s6 Sau do blim
OK
Trang 26Sgver name
Ilocalhost Log on to the saver
0 Use f (endows Authentication Use SQL Serve Authentication User name
CD Select or eta a database name
0 Attach a dabbers file
Logical name:
I bit Connedion
Tang plan vi MENET MVC framework
Hinh 1.13 Kit mil ca sa da lieu bang Entity Framework — but 4
Trang 27Sip Cheese lift Dale Connection
I
This connection ding appears to certain senors Ste as min* a password) that is respired to
connect to the database Storing sensitive date in the connection string can be a seasity risk Do you vont
to include this sensitive ft I the connection string?
0 Mo Delude sensitive ddb from the connection strig 1 wIU set it in my application code
Ye; include the sensitite dab in the comedian skim
Entity connection *ince
rnetadatarese/Modek.Maddlessairess/r/Moddadodellssa
rec/P/Models.ModellmaprovideriSystern.Deth.Sqlfleaprovider connection thimp•eleta
sourcerilocelhothinitil atelomMITAD;pusist security inforamemser
Tang quan vi ASP.NET MVC framework
nap theo, to chon Next
Hinh 1.14 Kit ca so de lieu being Entity Framework — buoy 5
Trang 28Tang Liman vi ASP.NET MVC framework
Cu6i cling, to biim Finish de holm Minh vies kit n6i toi CSDL ttl SQL, Server
Trang 29CHUZING 2 TONG QUAN H$ QUAN TRI NO' DUNG
2.1 quits tri Of dung hi gl
He quitn tri nOi dung (CMS) la mOt phen mem may tinh dirge citing de trq giop ngubi sir dung tong qua trinh quan nOi dung CMS lam cho viec tO chirc, ldem soat
va St ban mOt kh6i lucmg 16n tai lieu vi nOi dung khic nhau, nhu hinh anh hay cac ngu6n thong tin da phuong tien khic trey nen cll thing MOt he thong CMS thiremg dieu kien cho viec lien ket va mac n6i cac tali lieu voi nhau He thong quin nOi dung website la mOt he thong quart 1St co them cac tinh ning nhim giop giam tai sv phim tap cba nhttng cong viec dupe yeu eau de nit bin nOi dung da web ra ngoai Website 2.2 Tgi sao Igi cin h$ quiz tri nti dung
Trong thvc to nay nay, He quiln tri nOi dung ttuqc biet din &Si sv don gian vi tien clung cho nheng ngubi quip tri web, vtly dieu gl mang lai nhttng kha ning tien dung de? Sau day nem 157 do chinh di mang lai nhttng kha Wing tru viet cho melt He quail tri nOi dung:
He quail tri nOi dung mang lai sv truy c#p true tier* vao website cho chink nhitng ngubi viit nOi dung cia tang Web Phin 16n cac cong ty, ngubi phat trien web khong phai ngubi vier nOi dung cho cac tang web Ho don gian chi diit cac bai vier vao nhttng dinh don web co Sen Veri mOt He quart tri nOi dung, ban thin ngubi vitt nOi dung c6 the tv truy cep vao nhung phin ctia tang web de vitt bii vi xuat ban Chung
He quip tri nOi dung mang din kha stag 4p nh$p nhanh han cac ding ty khi to nhu ciu St ban hay chinh sot nOi dung cila tang web thi din ph& lien he
trvc tiep yeti ngubi phat trien web cba Cong ty Tuy nhien, khi gap nhang bii viit 6 18i hay phii nhttng lien kit xiu, ngubi pith triin web ph& chuyen net dung d6 ter lai ngubi viet vi yeu ciu sira chtta lai, va sau khi stirs xong ngubi vitt lai phii yeu ciu wen phat then Web xuit bin lei noi dung do Viec de se den den sv chom trl cho vier St ban nOi dung m Website Vol He quan tri nen dung ngubi vier c6 the tkr minh thay d6i 'Arc tiep tren nOi dung va hob thimh qua trinh xuit bin
He quail tri nOi dung cho phep lam vies vai mOt tang web ma lcheong can ce kiin thin vi HTML Hiu het cac He quitn tri net dung diu lim vies yeti mei trubng giao dien vi vey nen chins to can them mOt lien kit tOi mOt thong cao bao chi mai thong to c6 the nh$p tua di lien kit, URL, vi mien ti cac trubng khic nhau trong mau pain tri nOi dung He quart tri nOi dung se tv dOng xiy dung lien kit d6 cho chins ta Doi yeti nhttng detail yin ban dai, ching hen nhu cac thong cao bao chi dity di hau het cac He quip tri nei dung dit thong minh di them cac the dosn van, xay dung the lien kit va
Trang 30Tong quan vi hi quin hi nii dung
He quin tri nOi mang den sv trich nhiem Phin mem He quin tri nOi dung thlnh thoing c6 the duqc cii at voi nhitng tii khoin ngueri di ng vi guy& troy cop Dieu di c6 nghia 1i c6 vii tang c6 the chi dtryc chinh stla bed mat ngteri clUng dip biet vi viec thay dei ten tang Web duct thutmg xuyen theo dei boi cic cong cu quin lt theo d6i,
ne do the quay lei ter tang thii trade khi thay del nett c618i xiy ra
He quin tri nOi dung mang lvi mat lieu chi& chung cho ci tang web Hiu het tic he quill tri nOi dung deu lam viec ten mat he theng kieu Su Dieu d6 c6 nghTa la
c6 mat so khu Arc dui tang Web thi khong the 1:4 thay boi nOi dung cia tang web Bei vi kliting the lam they dei nhung khu vvc d6 di dam bio tieu chitin hoa cho town b0 tang Web
2.3 Cie (tic diim at bin cis hi quin tri nii dung
—Phe chuin viec tao hoot thay d6i nOi dung trim tuyen
—Che dO wan thio "Nhin lit bier
—Quin 1y nguai dung
—Tim kiem vil(ip chi mac
—Luu tra
—Toy bien giao dien
—Quin lt inh vi cic lien ket (URL)
2.4 Phan logi the hi quiz tri Si dung
Clic hi quin tri nOi dung dtryc phin loci then chat fling chinh cis n6 Sau day li
cic He quin tri nOi dung duqc sir dung rang rii:
— W-CMS (Web CMS): Chi h8 try viec quin ly thing Web
— E-CMS (Enterprise CMS): H8 trq tit cat khia C.-anh cilia qui trinh xuat bin nOi dung bao g6m website, in An vi cat diu ra thay the
— T-CMS (Transactional CMS): H8 trq viec quin ly cat giao djch that:mg mai dien tab
— P-CMS (Publications CMS): H6 trq viec quin cat loci in phim trvc my& (s6 tay, sick, try giup, thaw khio )
— L-CMS/LCMS (Learning CMS): H8 try viec quin 15r dio tao dva ten
it Web
— BCMS (Billing CMS): H8 try viec quin lt Thu chi dva ten nen Web
Trang 31CHTiONG 3 PHAN TECH THIET ICE lit THONG
3.1 BAC TA YEU CAU
3.LL Quin 0 bili viit
Tiling quan:
Chim Wing cho phi" moi ngubi c6 the doe cic bid vitt duqc bien tip vien bay
gain tri vien tang len Thinh vien dAng lcS , co the them, sus bii viet cis minh len Iron website Quin tri vien to the them, mkt, x6a vi duyet cic bii vitt tren he thong
Quy trInh:
Hinh 3.1 Quy trinh quein 0 bin vier
Trang 32Phan deb thiet ki he thong
M6 tal quy trinh:
NOl Admin
Hien thi danh sich cac bai Danh sich cic bid via
NO2 Admin
Editor Quin tri vien,bien SP vial
ding bai mei len he thong
Bai biet duqc them vao
he thong chit quip tri vien duet
NO3 Admin
Editor
Mi bai via Quin tri vien ho#c bien t$p
vien ap nhit bai viet
BE viet dtrqc cep nh#t
N04 Admin Mi bai vitt Quin tri vien duyet bai
vitt tbi mutt bin
Bai viet dtrqc nit bin
NO5 Admin MA bid viet Quin tri vien thuc hien
it& bai viet
X6a bai vitt ra khei he ditong va c$p nhit lai danh sich bai vitt
Chi ilk Sc viu cliu
—Danh sach bai viet
+ M6 ti yeu ciu: Liet ke danh sich bid vitt then cic tieu chi khic nhau
+ Cic thong tin an gain if,: Cac thing tin cu ban cis WI viet duqc a* dtmg lam lieu chi tim kiem
—Cic thing tin chi fiat ctia bai viet
+ M6 to yea ciu: Cic thing tin cis bai viet cin quan It
+ Cic thong tin can quart it:
Trang 33Quy trinh:
co I CO2
Hinh 3.2 Quy trinh quint I,y chuyfn mix
Trang 34Admin Then thj danh sach cic
MA chuyen Quin tri vier cap nhit lai
thong tin chuyen muc
Chuyen muc throc
a CO3 Admin
Quin tri vien thvc hien x6a chuyen muc
X6a chuyen muc m kh
he thing vi cap nhet 1 danh sach chuyen muc
C04 Admin MA chuyen
nave
Plain tick that ki hi thing
M6 to quy trinh
Chi nit Sc yen du
- Danh sach chuyen raw
+ M8 ti yeu ciu: Liet ke danh sach chuyen da theo cic lieu chi kit nhau
+ Cic th8ng tin can quin Cat thong tin co bin cis chuyen Ink ductc
cb,mg lam lieu chi tim kiem
- Cic thong tin chi tiet cia biti viEt
+ M8 ti yeu ciu: Cic thong tin cis bai viet can quin
+ Cic th8ng tin an quin it:
o Ten chuyen
o Ngay them
o M8 ti
Trang 35Phan dch that ki be thong
T6ng quan
mOt bei viet dirge oiling tren he thong Ngtreri ding binh Min kh6ng nhAt thiet lit think vien cna he thong Quin try vibe c6 the chinh rah hay x6a nhiang binh Min khang phil hqp vol nOi dung hay ng6n ta kh6ng phe hop
Quy Snit
Hinh 3.3 Quy trinh qua 111 binh lusfin
Trang 36Phiin &It that Id hi th6ng
M6 ta quy trinh
CM01
Guest,Admin
,Editor
MA bii viet Ngubi ding 14 chon
bii viet an binh 14n nhep binh lu$n cfia minh r6i ding len he th6ng
Binh lu$n duqc ding len Wang img vol bki
viet
CMO2 Admin Hien thj danh sich cic
binh lu$n tren he th6ng
Danh sich cic binh lu$n
CM03 Admin Mi binh
llion
Quin trj vien c$p nh$t lai binh lu$n
Binh lu$n duqc c$p nhet ten he thong
Binh 14n duqc x6a b6
vi cap nhet lui danh such binh 14n
CM tilt yeu du
—Danh sich binh lu$n
+ M8 ti yeu ciu: Liet ke danh sich binh lu$n
+ Cic thong tin cin quin Cic thong tin co bin ciut binh lu$n
—Cic thong tin chi tiet cfia bii vitt
+ M8 ti you ciu: Cic thong tin cis binh lu$n cAn quin
+ Cac thing tin cin quin lt:
o NOi dung
o Nguiti binh lu$n
o Ngiy binh lu$n
o Email ngirbi binh lu$n
Trang 37'Phin Lich that kE hi thing
3.1.4 Quin ly litho sit bin Spa
Tong quan
V6i chac Wing nay quin trj vien c6 the tao to cac cau hei de thy gep Y ctla ban dcoc hoec thanh vain, ti de c6 the nAng cao, ph& then he thong met each tat hon Quy trinh
Hinh 14 Quy trinh pan ly ado sat biu chpn
Trang 38Phan tich that hi hi thong
M8 ti quy trinh
KO1 Admin Hien thi danh sich cic
KSBC di c6
Danh sich the KSBC
K02 Admin Tien di, nOi
dung KSBC
Quin tri vien them KSBC men cho trang web
KSBC mai duqc them vio he thong
ICO3 Admin MA KSBC Khi KSBC mai duce
them hooc cep nh8t tren h$ th6ng
KSBC duqc c$p nhat
K04 Admin Ma KSBC Quin trj vien thtrc hien
x6a KSBC
X6a KSBC ra khOi he thong vi c$p nhOt 10i danh sich
Chi tilt yen clu
—Danh sich KSBC
+ M8 ti yeu Liet ke danh sich cic KSBC
+ Cic thong tin can quin 1$': Cic thong tin co bin ctia KSBC
—Cie thong tin chi tint elk KSBC
+ M8 ti yeu ciu: Cie thong tin cis birth luin cin quin
+ Cic th8ng tin can quirt 1Y:
o Ten
o NOi dung
o Cic lieu chi
o S6 ngtrtri btu chon
Trang 39TKO I 1102
Hinh 15 Quy trinh fining ki
I Phin tich that hi hi thong
Trang 40Phil' tech that ILO hi thong
Chi net yen au
- Danh sich clic bio dm th6ng Ice
+ M8 to yeu au: Liet ke danh sich Wm coo then cac tieu chi dm lam khic
Vol chat niing quitn lt tai khoan, quail tri ten c8 the kiem soar vi plan ljr thrqc
thong tin mkt cac Minh vien tham gia vito he th6ng
Quy trinh
TO I TO2