Mô hình mvc trong ASP

  • View
    346

  • Download
    2

Embed Size (px)

Transcript

M HNH MVC TRONG ASP.NET

M HNH MVC TRONG ASP.NET

TRNG I HC NGN HNG TP.HCMASP.NET MVC l g?

ASP.NET MVC l 1 framework pht trin ng dng web mi do Microsoft cung cp, n kt hp gia tnh hiu qu v nh gn ca m hnh Model-View-Controller (MVC), nhng tng v cng ngh hin i nht, cng vi nhng thnh phn tt nht ca nn tng ASP.NET hin thi. ASP.NET MVC ra i khng phi thay th cho ASP.NET Web Form m n pht trin theo mt nhnh khc trong gia nh ASP.NET Framework.

2MVCMVC L G?Model View Controller Chia ng dng thnh 3 thnh phn chnh:ModelView Controller

View: This is the HTML markup in ASPX pages. This is rendered in the presentation tier (the browser).Controller: This refers to a simple class controller that decide which model needs to be shown respect to which view.Model: This a layer who deals with data, which may be processed by the business layer.

33 thnh phn trong MVCModelc giao nhim v cung cp d liu cho c s d liu v lu d liu vo cc kho cha d liu. Nhn yu cu t ViewsTr v cc gi tr tnh ton cho ViewsKim tra tnh hp l ca data

Model:Trong cc ng dng da trn MVC, model l nhng thnh phn c nhim v lu tr thng tin, trng thi ca cc i tng, thng thng n l mt lp c nh x t mt bng trong CSDL.43 thnh phn trong MVCViewView: Hin th cc thng tin cho ngi dng ca ng dng v c giao nhim v cho vic nhn cc d liu vo t ngi dng, gi i cc yu cu n b iu khinNhn li cc phn hi t b iu khin v hin th kt qu cho ngi dng. Cc trang HTML, JSP, cc th vin th v cc file ngun l mt phn ca View.

3 thnh phn trong MVCControllerController: l tng trung gian gia Model v View. Controller c giao nhim v nhn cc yu cu t pha my khch. Bn trong phng thc ca lp Controller c th c thc thi phn hi cho trnh duyt hoc phc v cho view.Controller c th truy cp v s dng lp Module truyn d liu n cc ViewController s dng ViewData a bt k d liu no n View

Controllerl mt trung tm ca ton b kin trc MVC

6ControllerViewModelRequestResponseHTMLHTTPNhn kt qu tr v t Model. La chn View thch hp hin th

Li ch ca ng dng web da trn m hnh MVCD dng qun l s phc tp ca ng dng bng cch chia ng dng thnh ba thnh phn model, view, controllerN s dng mu Front Controller, mu ny gip qun l cc requests (yu cu) ch thng qua mt Controller. Nh bn c th thit k mt h tng qun l nh tuyn. H tr tt hn cho m hnh pht trin ng dng hng kim th N h tr tt cho cc ng dng c xy dng bi nhng i c nhiu lp trnh vin v thit k m vn qun l c tnh nng ca ng dng

THANK YOU !NhmNGUYN THY DUYNNGUYN TH MAI HNNGUYN THANH HVNG PHNG THANH