You are on page 1of 106
MVC 6 NEW CLASS NOTES BY MR.SUDHAKAR SHARMA SIR NARESH TECHNOLOGIES SRI RAGHAVENDRA XEROX SOFTWARE LANGUAGES MATERIAL AVAILABLE BESIDE BANGLORE IYYENGARS BAKERY,OPP.CDAC,AMEERPET, HYDERABAD CELL:9951596199 Desqn lateros: Design patterrs ave solutions to softeoaxe lestgn Problans ain ond again IP real-world apMfcation development s and Interactions of objects: ee cheat 0g design ‘that can be Honskomel Pattems are al “0 desig? patterns {pot a finyehel auectty tre code. Tt fs a description co) template “fx hoes te camying cut “his coremunication &> chaie of Response: Eucay of passing a request between a . chain of object Gd Commaral : Encapsulated! a asmrmatd vequest as an object : GD) oterpreter: © coay to include language elements fo a Peqram. wo Perater: Sequentiattey access the elements of a cottecton. WU Mectiatoy: Defines Simprtied comrnuniantion betussen classes WD Memento! Captus ond Yestore an objects internal state. OM Chaewer: A cay of nothing change te a number of classes Wi) state! Etter ao objects behapfeun when Its state changes Ww Shate gy? Encapsutates an algertthin ‘side a class ®) Template Methed: Defer-tne exact Steps of an algorithm to a Sub class GD Visttor: Defines a meso eperation to o class lotthoet change: Architectural Patterns: Ap archficctutiat Style, Sometimes called an archftectusal pattexns Ga a set of Piinciples~ a course qcloed Patter the provides on abstiact frome ceork fora amity of systems: On jecteat style Impeves PENtiOMary ond promotes cesiqn axchi reuse by Previdiing selutians: to Frequentiy yecuning problems. Mve: he Mecle\-Vieco-Comtrettet Cave) arcbitectumal patterns 00 applaation to Aimee mato compenents Separates a) Medel © View ® Coneuer res] EE tas Camel Le Uh uses oy Madlel- Ufew- Contratter (Mvc) fs a Softazne auchitectne Patten, e ORefral fernutated athe late 1440 by “Tiyque Ree oskang as © patt of Srnatt tally a Code cusability and separation of concerns, ay Oxqinatty ckveloped fox desktop then adapted Ay ictevnet opps Model: ¢ Set of clases that cesaiiles the data we are Loorlelng LOH as wettas the business ¢ Rutes for has the data con be changed! and manspalatec! + May contain data validation yules rOften encapsulate data stored tm a database as wetl as code used to manipalarte “the data . « Most likely a Data Aaces Layer of Same tonal ¥ ® pact From giving “he data aberds, it doesn't. Kaye ance In the aneucertc. Views | Defioes baw the applications User interfae (uz) wit be aisy ; May Support Master views (larfeutts> aod sub-views (partial View. «@ Web i Template to alyramscatly Jererate woe, ics Contes) Contuter! 4 The core MVC component pote Piocsss he YeqUEsts with the eip of views and ‘ reciels ve set of Classes “that handtes cS Comrmuniastton fron the user @) Qveatt application fteve CD Opplication- Sep Specific legfe y Every controties has one Gd more acttons Myc Frarne Works PHP. — Cake PHP: Code teqniter ‘ Yon — Sprirg Ped — Catalyst, Dancer ‘ Patras ~ Borgo, Hask, Grek Raby - Ruby on Rails, Campings Nitto» Stratig Tenocenph = Qrqulon Ss Gaus Sextp MVC. Spice Net Framatoat.~ O8PeNeT MVC the Mvc. Pattern Tov Web! HTTP Request mp Rec deb ASP.NET MVC Sewev Reuting Eropi Select Controller aind (| ae Street x Incoming request outed ty Coorwltey @-for Web! HTTP Request y Conroe processes Yequest and Creates Presentation mocet «) Gowatter also Selects appropate ¥esult(View) » Medel fs passedi to view ve View ransforms meclel into appropiate eutput sforemat CHT MLS ¢ Response ts vencleracl CHTTP Response! eb.ney MVCS Opplicartion Life Cy “ae | > devel Mew ; tin application fae Preiss cos] uy een an prccessi0G PRAOS [Resa I] G) Rectevefivst Request Téythe applfastion Ip the achat. asax fie, Roane ckjects are adder! to the Rerste table dere cor Perban Routing: the rl Routing edule uses the first matching Route object th the Route table coltectin to Create the Route chject, which it then uses to Greate a vequest Cont extCANTTP Contest) object ® Create MVC request handler : sre MVC RuteHtandter objects: treates am instance & the mychandler class and passes it abe Request Comteat tmstance. @ Execute Govetter: =the Mv Handler frstance calls the conttetleis Execute metitad ‘ (BD dmvoke Action, Mest corsttettes tobett from the ambolter hase clay “or Coptrouers that alo 2, Ane controlicy actlan éMvokes object coat I ascocfated wrth the contotter determines which cotion racthad di the contwiter class to calf and then chits seat methal @ Cxcecure Rewt D typical action method migdt Yecfeur sey inpats Prepare The appropriate response clata, and then the evecakad the vesult by sete ct YeSuttt type: “The built in vesutt types “that cir, he executed (nclude the fatioct ad ViewResuut (tohich verdes a view and ts ors ofterm used wsalt TYpd, RectweaToPyete- -Resuth, Redivect Result, ContentRescaty dsorResct anc empryResiit . Request fire: Talfereces Bereocen, Bsb.wer web Buns and esp.ner ve esPneT Wed forms ASP.NET Myc 1 psP-xer webTerms fates a 1. OsP-neT MVE IS a light wefgbt traditional even chiven evetopma and -fattoco mvc Cadet vicw aed controle) Patterns based Gevelepmert model >. @sp.neT webform has Sewer OsPwey ave bas HIML Hetpers rooctet Controls, SB. @SP-neT Webform Supprts 3. ASPweT MVC cloes not Suppost View state for state Managem View state at client Sde 4 OSP-NET Webform has file based LETS means-files mame URES means LTS Me divided into ext Inthe URIS mus have Gontotlers ard actions aod toveouy p-espnet uve bas yourte -based Tes Physfeatly existence Shs based on conttaller Not On Phystoal tile B-OsP.NET web farm faitows — 5 .ecp.ner MVC fatiew customabe web foxms Syotam. Segre (Radar 08 defarte) 6.4m EP NET Web form, loeblews g fq AD. NET myc, heslayoru es CASPD We Views Ore tightly Hse camsiireet leok-ermdfoeks, Coupled to cacle bebrod CASPx.cS) Views and logic ore kepe be loge Separately a OSPNET toc form has 4. Ap KET MYC has Lagauts master pages fer Consistent lock. fox Comsistent look and feele ett has user controls For a. te has partial views fev cde a veusability ye usabitity ot bas built in data ntvals Gad oy Jt IS light woe ht Provide Featt best for vapid evelopment wrth contel over markup nd Seaport mxary powerfut clata access fectemes that tous fost and agile eveiopmest, Hence ft ts best fox leveteping (rteractie web appltantiery Wits latest web Standarals rorasprner toeb form 5 10 ASP.NET Web Mve fs on Open ret an open Source: BuRce ASP. weT Mvc. featties, # Runs on top of ASP.NET AD Not @ replacement for web forms, @ Leverage the bevefirs of ASP. wey 4 Exabxace the web as User | Seo Arenas UTS, HTMLS SPA @) Odep: Rest concepts w« Uses MVC Patter A) Cormentions are Guidance ® Separation of @ncems ae Tight Grerol over ruleup « Testable + Leosety + Convention over Comfiq uration « Razor View Engine aS One of -ihe qrostest View Eneires G Lith lotelisemse, integrated fm Visual Studio + Resuse of cument Skills COR LInm, thML etc-~) Goupled and extensible « Eppication based (hot scripts like php) Seperation of Greens: ¢ Each Carsponent bas one vesponsibiey CD SRP Single Responsibitity Prinerple Gs Pey- Dent Repeat yourserf ¥ Move easily testable ao TD Test -Ditven Developrrng w Helps Wh Goncuasenr “deve toprnenp ay Performing tasks Comececuen thy and one Cevetopey works on Ulew God aneher Look Om arntratley . Earensiie ! v Replace ang compenine of the Syste + 4pterface based architectane « Dimest angining can be veplacecl Co extended dS Model ‘bindevs (Request cata €o erp objects) UD @ctin Result RurersCeq! Ov Octinekecuting) WICustom action vesurt Types. Q) Nieto Engine (Rasow webfouns yN Han’, Sparky Ww Views betpess CHTML» A tat y URL ete) * BP Custem data Provicers (ADO NET etc Gean URL's: -y ResT~ Like dy [Peeclucts|update ai) \bog\peses| aorg)i1)28 CMe -fs~coold 5 Flendifes tp hurnans (y [Products-aspa? car Id > D3 ©» Pest. PhP? f= 3 (iy Becomes] products! chocolate] ~ wy Reraties to Web Crawlers > Seexch engine epimmation CS€0) asp NET MYCE Ledoey, foster: emvcs haste dependency on System loeb. AM the yesull ts a leaner Pramootk volts faster startup time and lower tremor cansumption ae apps cam use a cloud cptimedt run me and atkset of ¢ Ne of ane framework ts about ane «NET Frasnewort “This sribset cs meqaryics Ip Sixe Comparer) to 200 Meg bytes fox “the fu Kamewert, and % Compased of a coitection of Ruget packages v Becauige the cloud Optienied treimevoorle FS A coltecticn of NuGet packages, Yous app 6a foclucte aly tthe packager fot actually heeds No unnecessary emer , Uskspace, fending time etc, “piconet can orton Updates to -the frame cork en = exer cadence, becouse each port can be update fren Toe Gale by Sete Depogeant! pak sl Urclepreho, Aycthe Yecluced fect print of the cloud -optimited vuotime makesit practical yuOtime Makes Ik Practical to Aepoy “ne eammeucore LOD 4pur app. y \pu Can Can apps Bile by Stele eorth aliHerent verstene of the —Rermeusork OF “Ihe Sorte Serves Ly our can makes framecorks upclates for each app co its cus Schedule : _s Ne extors Bhen epu deploy to production resulting From a tnistmatds between the fammecsak Patch levet on “the eleveteprseot machine and “the praducten-sesucy New> DBeyiow eto Revetoprnent Experience, menNext uses tre Rosly> commpiles to cnmpile corte Ayoarmreatt «Yo can edit a code fie, ine changes wfthout sebulidtog ste prajeck a Besides ® Stream\(nfng the clevelopmenr Process] qname Code crepilation enables Aevelopreyne Senarfos that waye tot possible before each as edttiog cede 00 the Seyvey xefesh ne braoses and sce ustog vrsual atudia onlloe C'ponace') —e You cad cheose Your awh edliters and tools. OP net MWe Retease Histon; Tete Newsion \oih Dee 2004 - @SPneTMVC \5™ March 2007 — ASP.NET MVCI-O eth Dec 2009 =— sp NET MVC2RC T? Feb 2010 — ESP. NET MVC2ROD ot) March 2016 | SP NET MVC2. et Oct 2010 — @SP:Ney MVC3 Beta "Nev 2010 = @sp-netT MVC ee 10" Dec 2010 - asp. Net MVCSRC2. 12" -qam2oll - OSPNET MVC 26% Sep 2011 — OP NET HVCG Devetopes Previers 155 Feb 201 ~— espet MvCG Beta Br May2op- — @sprweT MVC GRE rs Bugqrer — OspweT MVCG acth May rem — - Osp NET MVC4- 0: 30566. & oth Junc201s - OspneT MVCS Previews para @uq 2013 ~ OsPweT MVCSRC| ta deck 2018 — ASP KET MVC5 \o" Feb 2014 ~ ASP.NET MVC Sle} 14 dan vo1g ~ O9.nep MVC BH 4 Opi 201g - ASP MEF MVC 5.) a. 204 June 201G = - OP NET MVO5NB ys daty Dow — @SP MET MVC 5.26 oe Ouq7ro ~ OSD. NET MVCHO-2 pels MVC Destgn Patterns: The cso patterns cre Soltrtfons for solic HOO lee qe problems cthat qour find fo reat world oppliateny clevetopment « Ratterns are about veusable designs and Totevecttan of ohjects: The 23 Goq¢-C gong of @ pattems ave ooe ratty consiclere! es be foundation for alt cthess patterns ectbey ave cateqefacd thts 3 yours « Createral * Structural « Bebautovat Cre afonal: eat with instantiation fe creating of object “The Popstar creations Pattern % Abstract factory, Buticer, Hhdory meted » pots type, Singleton _structumal' Mthe souckunal pattern ate about destgntng of class 2) and descibe yafous implementatian mechanist hey are Adaptor, Bdge, Compostte, Decoratoy, facade, tly Weight, poy Behavioral Pattern: Define the scope of chject and specifres hece “the consumes the Yesounces They are chats of Resp, command, inverpretet ytterator medtatoy , memento, obsewert, State, serateqy s Template method 2 V sito. MWC, a\r's mye, Giedet View Cootroiter) a MVE ?ean seftccare archtreture pottan & Vettecluced ba THY QVe 4p 19440 Cod formulated wth the lonquage Wsman Talk") « Code separation aed code veusabetste of concerns. « OF Goong destqoedt for desktop appltcation « Now betng adopted by we application - TTechnatogies ascry (MVC Frame work Techmtagies mvc Framework PHP cake PHD, code tqciter Faun Sping Pen Catalgsr. Dancer Pron Dfacqo,flosk Grok Ruby Ruby co Rails Teva Serfpt sptve Anquiar js, Rock Bone js eNET ASP.NET MVC Evotutfon of mécrasoft Sewer Stde Technolagtes’s tHtstory &_ASPOS Years)! aq 6- © cre Sewer PaqesCAsp) 2002. — ASP. Neb 200% — ASP NEE MVC 2010 — OSP.Net web Pages Dold AsP-Net web APL, Sfgpal R poig < OSPNEES Netc: : Aep.oet ave ts just on alternative to aspenet voebs Powe and not veplacement for webforms. PAP-NET Webfomns VS OSP.NET MVC: Asp.ver_woekfens: yest LE |» 2s6P.BLL 2 —| \ yal Client sevvetw Tr is _~ SsaPporl va Rast }SGmiead) ts Lun titre class “ Application object A oe OsP.NeT Myc. (Pattern for webs: leb Sewer ——> @SP. Net MVE Routing Engioe Select Conbolier and. Twke action (method) Contiouer (C4 Class ‘Select View “£ Poss data Crecctet’) eRvDd wmadet “Haw Engine] Geo | Ue medlel Berta, Mectel: © set of classettte that clescithe the data we axe Workin, WH as wett as -the business d 2. dk contains votes that define hew data can be changed and manfputated - 3 te may contain data validation toutes. Gg. te often encapsulate data Stored fn a dato hase as well 08 code usec te mantpulate the data 5. de fe most likely a data acess layer 6. Opart from qorrg dete objects tt cleesntt have any enqrtficance fh the framework View! \ dt describes the applicction usew wtevface. pide Supports master Views (lagouts) and Sub views Cportfal views ov User Gontels) 2% do web vieo povtdes Tempiate to ctyramicatty openviert: UML The coTOMoBlY used Ulew Engines with MYC aye: Razor + @ Name ASPX —e <%= Name % > Spark—t $4 name} Nhom@ {% Name} Choogo Cina} Controter’ ade % the Cove MVC Component + Te process the vequest whth the help of Views and Models. y4t tsa set of classes that handles 4 Goeomurteattgn fom “the user * Qveratt application -Hows 9 Qpplication -Specific logic + © controller Contains (etheas abat respond to veufous bttp vequase, thence these metteds are known as “Action Methods ‘/ esPenet Welb—forers @SP.NET MVC. ASP webtoran uses a Pege 1 Mve uses frentend Gonticiy, ceobolley Pattera, where Pattern, where att pages wir every Page wit have tes USE A common contraitey dion Centoller a Te Uses on oppiestion and 2 Ne more page life Cycle, page Ute cycte to Send Reponae only Recuuest Crete 3. Poutdes o buge Comtral Bde fe completty Uigbtiocaghy Utbrawy and Yequircs lots Os Te leverages the benghies of Sexwer Side interaction, OF JRUery and PYjax. ard View State 2g Aeghtly Couplecl and hard 4: Lossely Coupled ang to test Supports test chive devetspmant 5 Wit Pot Suppovt Cormpletly 5. Wil Suppove Complete WML HIML. etete Rep(Raptd Apple, Develop) 6- Not RAD WWihak's nae Te uveg) Casp.veT @5) + Bundting and Mintheatton + BootStap stach PI »Seqral R Jalbat!ls pew im Mve 5) 1 Hiltcy Querrideng 2 Otefbate Routto. 3. Unabrustye Jauerq Valiclotions hor fermote Vati 4 Support fox BeotStiap fo Ecliey Templates ry WER OFLL., Signal RX c Heotity —Open DD F New Templates —face book, Jwetres, APL pibatls neue % MveS? Ly Webforms + API+ MVC = ASPS ap hous new th MvCq? |. OSP.weT web MPT 2. Refreshed ond modernised defautt project tempiotes 2 New fodblle preject template : q: Mang new feciuiyes to Support mobite apps 5. Enhooced Support for asynchronous methods 6. Bucating acd Mintication t- Routing demprovemonts, & Bootstrap Ch Siqoal R 10. SPA (Single Page Oypplicartiony) Whetls news tp Mvc5? 1. eter bute Routing denprouements 2 Bootstrap Support toy editor templates, 2. Enurn Suppoit te Uietos qé Unobtustve validation for Min Length |MaxLengi prtpibedes 5- Supporting the "Ebes” Context Po Unobnusive QfeX 6 Rirex Quewieleng 4. Web OPI2,Siqpat Rr s- Adentoey—O peo 1D [dbotls neu fo Myvee? Le pse Wwebfixms +OPRH MVE =MVCE (AsPs —vivext) 9. Meclutay : Frame boon chips th application 3. -fastev Devetoprrent Cycle © Some code 1uns on Development ond Reduction & Open ounce WHS Contributions &. CxassPlatforns ~ New Frossu loork for Linu mic é. Age Ci Fs a method) —Uses Monaco, htc fs enlt & Re RS) 7 7 VES ual Strscli Fe Cheeta Reacty ~On Pemtses ts Cloud B New Rayin Conptler J Tur Stcte by Stele Developm nt - Stde sq Bde Erection, 3B. Suppost fox Matifpte Servers We drbutit- Support for Dependency “Injection - Bower = Grant v * NPM ~ Na@et ~ Gitbab — Growl 2 Every Peatude shtps lke package 13 QWIN Abstraction ,Odata 1G. Tog Hetpers fox Me Cootrottey | Controter Base —& Syskern, Web MVC 1 Must be pubtéc 2. Cantt be static 2. Must have o Yetwin type Gt Can be pakoumsterised oy Pelormetcy LK 5 Can't have vef and out params 6. Cont be qertlc bypes 4. Contt be extension rnathods x, Conte ovenicle : a, Con overtcad (on Can't be any mettad af Contictter base Me Cantt be marked wltr obsotete or Neo HcKfon Méhedg v You Cant ase No (ongt-f AS Creating 0 new MVC Application, » Le Open Visual Stucf 2012 2. Select (Nea Prgject 3 Lanquage as 4 Visual ca 4 Geto “Web" Cateqor and Setect "aspmcer web Opp” 5: Specttig © ame and loaater for @pp G-Tteen click OK 4 cits wotu Prompt ve to Sclece ao termplate as. Setect "Muc" termplate then click on asthe baste tte system of ang HVC application Comprises of Foucusing Ceempoments Fae |foid ex Desorption Opp-Data Pee ee databosrfs, af) Ppp - Stat Contoims Classes that axe Intended 40 XN on application Startup —fiiter Config. cs - Route Contig.cs ~ Bund te Coriq-cs ~ StartupAuth. CS Contest Cantars con alynamfe Bes like ess,imoqs etc. - Coottouers Contains Gontroler classes -Foots Couectior of fants ased by tock strap Models Contains classes that are tesponsiht, fee tty interaction Lott data bays Views Contains applfeation UD — Views — Rartialviews ~ Layouks Setpes, ae Cantafns ou Agnoenic Ler : ic Peleg, Globalasar —. G@lobar Oppleation otasg fe) < e. Web. ora ~ OApplfeatiag Cootgquration Fle Myc Gppifeatfon thgb Level Bes ‘ Deseqn; over, cipeline Uk PAP HRcattend v pevllessina Pi ate | Bipne (OV (eer a Cxeattory |) | | Rating coon, \ Qethentiation | | a | [| nes ' Recdicy\ Ls onl | Bestel Binding Resin [Cease | Tes I] eeetc J / f Ectton & controler fa class detued ed fyorm Spvecettiony Coot Fares) Creating & See Contretier tbe base Contrater defined under "Cy sremrine boyd Ve Bropises, OF Methads dhab yespond to varfous HtkpVverbs :GBr, Posts PUTS DELETG ete. 1. Regbt clic on" Contiatiess" Forder In MVC application 4 2. Seteck " Ddd—* vew —» Comtiolter B+ Seveck controuer type as “MVC Ennprey Qncrotter” be Click "eat 5 Ines usftk Prompt you © define a nome “by Controller, and every conkrcliey Mame cmust Use The sufbiy “ Controney” — @' Products Cantroiter 6s-Then Click ot Syptax: a Pubic Class Hreducts Gatratter 'Contower SS actfon (Metheny Acton Methads : Ihe actemMettods ave controller Methods that yetuan varfous Valles as a resutt-the fantow ing Conventte to be fatiowed % order tp Create 0 controuey method pene 1. © cectictter cctfon Method tus be public. 2. dE Cantt be Static 3, de must be defined woth a Yeturn bye 2S ever actiontnettod mast teturn a value Can't be os ter Cam, be panometetBaecl of Parameter (ess, 5. Canit have vef oF cut parameters. 6 Conlt be qenette types: 4. Can overload but conn! Re pik be ab extension method. t be cvewide se ey “ u mottod of base Gntrotter Clots qe cant be any “obgotete | NonOcHes A@bentbutes. ~Cantt he marked wrth D Cx. pao’ pabife class PodecesCntroucr* Gntrouer ipo sting Detafis (tot? ta. stfoq Nouns, double? Price) Neruns "Predack Tb: “4 a4" by >" "Name z+ Nome} ver ly Wee a Request Suasy Ste ["Petee "I; 4 Set your action Pry Stor bap? 1. Goto" Opp-Sbar "oid ev 2. Open " Route Contig. cs". youtes. MapRoure C name Defoutt”, urls "f cootitter} | 7 ction | Ltd} Adefaut8: fo. fd}, aut: new controler > " Products actrons " Detalls} D5 Ex WtParameler. Optecral } Ealing the Canmoucr action: \ 1 Ravareter IP beep sft Lecathastdl od £ oon ke Pill le lemony] procscts| deteaf ls (0) Moroery flosing UVC apptfetttay on Irs: Pitce = G5000 var te Pigne ek on Pagject same fy Solution Explxey 2, Sctect "Properties!" 2 Geto “Web* Cy Gj Setect Sener as “Local £8" 8 Click “Create Utrcual Directovy jos? A)ctonResutts fm mye: © comtoter actenmetiad can be define woth Various Yetudo EYpes AS ActaoRugall encapsulate we xsell ot an adtionmetiod and used to perfocmns o fearon k levet apration co behalf of the cicHommetbod Uke Netaning a lec, fle, Ison, JavaSaxpe ete At actorsesutts /f MVC cus derived from the base YoctionResuit! wh@b defined under System: be beMve Aretion Result Helper Method VfeoResceet Views) Dacihat Vlewheesutt Parteuiviecat) File Resutt Rec) deonResult qsone> Conrentesutt Cententc ) Aovadcrtpr Rese davaserpok CD ‘fRectivet Recut Reclivect (> ReaivectToRaute Re sutt RatrectToe) cont > ViewResutt} Sr vepactents a class that & used to vender avieus whenever the cantroller action & thvcked the Utew Engiee al qoacmiccattey vender HIML to cleent. © cootiotter Action can return a view of any one of tte Fanowing cegpes. saspx *Oscn «cshtm!} + vbbtrol Ck! VCrveate a Seu action mettzad to Pederetsotra! by publtc VUlewResutt OetoflsC } Vetuan view); 2» Rtgbe Olick an Acton Name and Select “Askl Uiew" View Name ;Detafts Temptate + Empty(wtbout rode! ) Setect the cheekboa ! Use Maestev Layout Details. cshtm} chit Podurk Detatis Note? B convoter acten Methed ca = cey fs aove? £ Ulery. Howeved THe es pretey fs qve o have mere than one “Pe ° ts espa 4p order te access aspecitic vec you bave to tention the View Name. pubtte UtereResart Detaflsc > “bao suiew wl Views { Radueds | De tafe cshtont’ ". ssthy data flcm a controtier to Ufew! MVC Ppreovkles severat deyrarnic expressany and fropertfes that culers tre UT te Stove values and ramspot them acvass muittp ters: Sysrens. Web. ve provides tre fatioustng dycamte cuparessions: im yrewrBag 2 Urebata Cet 1. @dd a Kew action meted frto Products Controuet. pab\ie VUtewReeutt Detafls CD ¢ a Ltec éstring> Users= pew Lise csting $C S “Jobo "Davia; * Rabut " i \lewRag: use user lierestiing > Products = meu List chid Products List efi
    @toeachGor thems th Clarceue 2) ViewDat waar ker| ¢ e Uhre, LLO@ fteces etfs Peduct®p ¢|th> wre ers Ztb> Deduct Nameclths as se wo ct» Product Pre <}th > of roa < tb» Actions 2) th» @ovecchCvar Pte €o Mode!) “eX etd »@ feeem-Producttpelta > Zid>d & tem. Namec|td > Chad @ Them. Price citdS Zhd > @ Hem] AckonLink ( Detafis", “Betatis” , alta> new Lia = therm Poduct£0}) 2 tas 4 zltables 5 Add a View for Details Actton Narme , Deratls Template + Ep Matet class; Product@Models) De tatle-cshtm} model MYCEPP- Modetss Prodesc? abs sPreduct Detarlszibas a tabte bheraer =u y's e ates etd >Preduct op 2 Jkel s Practuct Mame 2 tte s bd > Medel Name cltd 1 J Product Prtce GZ Hew Beton link C" Got Gedex" ndex“’) SP. PoxtialView Result’ | fe repAtents a bay class fe & used to Send partfal Ulow to the response: the Parttal uiewis cive Yeusoble Prototypes that ave accegsfou fore and Vier. Nhe ove SGrilar to web usey comtrel fo asp web fover, ex! oor 1 Geto Reductsces and add a new Beld. ees pabllc String Photes dgetj sets) a.Gate "Prodects Data-csane photo for every Proctecce Oe bea SPreductDD=1, Naty = Mobile", Price: 1.000, phe to = ‘~1 Photos| mobiles by 2 BiOdd a new ford ey Bame fropost 4 2 tages foto tho foldy. 4 Geto Pveclerets Co ntvoller oye} 7 add fouceotrg cxctfons pubtic Partial viewResatt ProtoType C> yeruro Pactfalutew ¢ y 7 pablic Vtew Result drongedrdex 0) yetuae VieusCdlb- Products iit. Tolisee>> | % 5. @dd View fox Prototype Name + PotoType Template t Empty Model Class : Pracderet (Models) Ricveate 03 Pastfal Views Potsrype- cabtet| Goedel Muc@pp-Madele Product ekabie bodes="1" Voiclth> "qoo" 5 <> eta cfg sxce 42 Content (Medelprotoy a|> lta iat = "200" Ketgbt=""200 Ztds eZtabbte bovdey= "1" S Z2tys 2 tas Prodect 20 ibd > zked ~OQMedel+ Prodewt 3D 4 [ka > ales 4trs Ztdr Prduck Narne Zttdl > atd >> @ Medel. Name < ta > 2ite> Ztd>y Product Ptee elke 6 bap @ Model. Price cteas Weagedndex. eshte} @medet Ténumerable< Mve Opp -Medet s. Pracluct > v aha >Pradaces Sreage Index ctbs > €& foreach (vax Fters fn Medet) L@ Reel. Partie CX Prototype “s Teeny) (@ Hee\, Render Revttat CPotetype’s Tem) 5 4 Xe x . Re Qeccessing Data form Database YAM O00.0ET » Enercy Framework ¢ @bo.ner EF |. Microsoft inevoduced Enetey Aramewerk Rom eet “Frama esavic 8:8" 2. Ertny Frarnworls Poutdes new mactipls model techniques like code First, Database first, Utes fies, 3. Entree, Promeoork Supports fuu Provider mede| “that: can CammiunPeate wit Sar Server, oracle > MyqSat, DB2--etc CMangatsts) Enany Farms tou k Orcbteectete Objaet Services Sewtices Cnitity. CUenrBata @pe-wer fata Proud er] << tobass te The entity Bota mace! Compisas oF “Hove = rmatjor Carmponenrs aCenceptual Meclet b. Storage Mode! . Mapporsg 2d. Eoncepkeal trode! SuUpactentS the data You are working with ak well as ~the bussiness . a 2 Medel Contatne the data Mopring gon gontaine irstovmecion that specify hocw Zercoptucd reectel wh. Gorerneunioals uit op. 5 LINO to Eniftres $ Cottey SAL ave Muay pprenches gribece quiry oppreaches ave translated Unto database native tueres useng & Cltent cato. Drow 4 dex - + Object Services fs amain every point for accessm, athe dato trom Gatabase and yetaan ce back, fk rs befor meteriidation which is Process of Comperting data retodos fan cost edo Ey, Ao 7 . Frame Werke Library® entity client cleuta Provider to sy Exvetey ve, ches @ CORY Obyent Séruuc hers System. Data. Erttty ty oR sche class Thesaiiption @ Dbaontest thstance represents a combénattcon of Yeposttory Patterns, ohh ace used to fom aclatabase ond DibCorbext Query geo together the changes. ancl yetusn back boty clata Stove as oa unt © Cbset vepacsent® the coltection of Entictfes im the context te Fe xeponsible “bx Quertrgthe catty fiom a spectftc datn table. At defines the soateqy Uke ate CA MEW database Or to Doser Datdlease cre’ uge am exfstin database. fo - ) C* Qcewssing Deta Fiore DB using amo-neT EF: Step- 1: Desqn Database Create a new 8 by pany uMUCPreductsDb” ~ edd anew table by pam “EbIProdects"! ProduckID OPK- Identety } fhe OL varehay Kee manet Se Pp>. Deseqo mvc Appltcation —Cteate a deo MVE Application ~ Enable Esttty ammo Coptional fr 2013) we Reber clic on References —Manaqe NuGetPackaqyes ~Setect Enttty Froumeusor ke -Unstatt ~ Goro web-Conttg and lertte “the Gonnetien sting eCennectionstrings > codd came" ProdecisQnnection” provodievNome="! Sterne Data. SqiC tent" connectionString > u Data Sources a Joitral Catalog= MucProducts Db, dnteq rated Secutity = Sopp. usér td=Sq ; passumrd= 123" > " ee ~ Goto Medets fidex-and add a new class foierthoere . _Peseuses! Sesto. CamponentMadel 5 using Sxstern: Component Hodel + -Data annotations. SChwnas Etable ¢' ebiRedaetsD] public closs Preduct x Deeg] publec tot Reoduet®D See set public String Name Sqersseey public. cecirnat 2 Paice LgetsSet } 4 Odd Accther class fite f " Precucts Conterb. es" ato models by oare using System-De ta. Ente : 5 public class ProdectGortert: DbCentexct public Rcductantext 0) + base Cirame =PodeetsGore 4 - ction“) pubic BbsetcPredestS prodectelict Lacks Lb} 4 ~ OH a pee Controtter by Dame “PraclucksGntrouer” usteg Entergy Myc. Macdlets 3 Public class Prodects Controlter 7 Contrower £ PadectGontexk Abanca RodustGonbet >; public VieweResuth Jrdext > ‘ Tetuan View Ld b. prodescts lest TSLESE CSD 5 pubic ViewResubt Detafle (ft fd) 5 xt Yeruan Veco Cab. padercts lise SingleC% xy ke Reductan 4 Ss Fads 3 — Odd View for dedext Action Name; Index Teosplate + Compt Medel Class: Produch(Macdlets) fodiens Cshten} code for_frdex. eshtm) :- @rwodet Deoumerable TErbitey Mvc. Medels. oduct s chad Poduets Index
    eths Product TD 2th> Pedust ame Zftbs Produot Bice elths 2tb> Octions citbs @-foveach (var tem fo Model) L ces Ctd> @ Tre me Poduot PH cltds
    Qftem. Name éttdy ZtA> @ teem. Price Zttal > Ztd> @ Html. Action Link ("Detalles Detafls’ y ce Dew ide teen PreduetTO}) sites Z|table > Oda of view for Decinfls Bction Nome : Detafls Teropiate: Empty Model Class; Predetct (Hociets) Detatis. eshtrol cede! “@rnakl Ertiey Mue. Models, Prodan cho> Rekeets Debafts clhe> etable bere "1"> ets Ltd >Preduet id clted> Ape > @Medet.Pradusk2D ibd > cs 2 tds Preduet Name cltds tad @Medel Name c |tdy cites cys cas Peduct Déce clta> Zidd @ Medel.Prtce cltay Zit citable S Zibr> @ Him actton Lick ( “Gato Incew"s ugnden'') > Click om 5 Note! Set database Jotifaitze te define the strategy ~ Ge to Glebal-asox — Wite-tne tonewiry fo Appifeartion-Stoxte > Dato base. SetJoftiatiter Reducts Gntrottey > Cou; av Fite Resutt | t repacionts fete content to te respons] Tf browser Es a base class that fs usecl to send bhaxey suppovted with MIME Types then fk can vead ov downland ane file Syneax! public fiteResutt Qctianc D t gape Tepe" Vetann File CU Path’ “MIME Type ds ex! pubttc FileResutk Action > von Five (hv| Context \asp.pa ft ‘opplfcation | pdf), ‘ JeorResutt ! Te vepaesents 9 base class “that fs used to seo Uscn -formattels Gontent to response. dt woillt Seffattie the. Content aod make tt avaflable offtihe. © Syntax: pubttc FeowResulhs } Sctionc 3) WetuAn YsonColect , Aen LeqnthB elraistour. HrowGet’), i Ex: public FroResuik Uses (> < Légb< stitaq>C> Leste seving> ses =meto x “Rabel 5 & Daniel’, * Yobn’ 5 yetoan Fson (users, Kok ‘ RedivectResuth: Tk conticls the precesssng of appifectiions actions by vedirecttng to speed Ure, db cap be Used) within ey bleo applicakfeny. Syntaxt public RedtvectReeue ectionc > equast Behaviour. ChowGet) 5 xetann Redivect ("Utd"), ©! public. Recttract Resist Pspret ¢ > a return Reativectt “http asp. net lwneat “) 5 3 Rectivec! To Route Resutt, tevepresents a resuth tak performs o veclicection by useng the specified Route values. dé can be usect to Yeclreck te any asntrotter action wethin the application Serex' publec RediveckToRouteReauit Ectiond > { retian RecliectTo@crton ( ActtonNome", “CostoltedNon’), ex public Redirect ToReuteResutt Procdercts hist) £ rete Redteerioctton CH Indes" “Produces; % ContenrResult? Ab yveprescots o weet detined content type “hse és Sentas vesponse to the cléent, ft alse can aetine the contest type ond fs encoding Syntax Pubic Content Resutk Sctfarc> vetuan Content (4 String 4 eM IME Type coco dg) 5 Gti pultic ContentResull Sareplecy Yetutn Content (“Producks"; applicotton| aml, utt-s>, % Vevascsptbesutt: te ve presents a bose class that sents Jeu . Contant to Fespenas: Youncan cat.any Java Scspe function, oO use a davoSetpr Sbjeck to Send as a vesponse. Syptas! putic JavaccApeResutk Actionc > Yetunn tava eRpL function) 5 % Expry Resute : Te vepresents a resutt that Teturn bething- So fe colt Pot have any veto vale: Nou cam use Such vesutts £0 aeess from ad anesthey action Note? Fu action methods 5 a aonhotter ean be frroked Atectty by UF vequatt. Imarcter to Maik te oF TestHet Br ts accessbfltty you have to use the exttifbute ” Noniictfim” Gre} CNem@Q ction > pubtie string hetloc > YetUAD 4 tHetta Word a % public \iecoReault dndexe> ViewBag- sq = bette oy; Yeruan Vier )5 % Index. esbten) @ ViewRagemsg < yin} Yee CRUD eprentions using scafbid templates fo MVc BO and 3 layer orcltbecteve Skepti Design yee detabose — Create a pew database in sab Seven by name \ Products? ~ Qdd a seo toble by name “tbiPoducts Product ID Pk Identity) ‘Trt Name Narchar Pktce Money _ Create Stored Receduves Procedewer Scion PGetPredactsS — Petarn att products ePacdaProductso” dnsext a. pew product spUpdate Poder Update proclact by tes Cl epdetetePraduct & Step-2* Rentgo ppiication Data @acess Layer Delete predact by tts Td — Go to file menu add—bNew prajeck ~ Getect "clase Library Preject™ — Name teas “Dataeceess Layex® — Ureport the Reference “ System Configusiation" ~ @rll a new class fite by Came “Products! public class Roduct pedic tor AetuceDs Lyets sek} pubic sting Newme €qets sek; public decimal) Pice facet 3 Set52 q 6. @da another class -fite ae mame “ Prodeckcpud.cst using System Dota; using System. Bata. Sql Chrent;. using System- Corfe uratton; namespace Data @resslayer pablic class Prodesctopud & sing gtieen> CoofiquratiorMarager »CommectionString. PPreducts Commection''] sTostringl 7 SaiCormection com; Sq\Qonmana ermds HWReaa Operation pobsic Penumecabre ©); con spew Sq\Connectton Caecean) 5 Com Open 5 Cendsnee SqlComma nd sPGctReducts", con); salBotaReader dy= cmd Execute Reade 6; While Cav. Reads) { Product product pero Product c> 5 Produck-ReduckD = Convert -Téttt 6(ArPProdesor2 5), Prodasct-Name = ar [Name] Testing or 5 prodast Pee = Comet “ToBecemal Cdy{" Prac S, Products. Adla(breduct) a ck. Closet D5 con. Closet); 5 Yetuan products} + Se Il Cxeate Operation public veld AddRoductCPreduct precluct g com spew Sql Connection (Str Con) 5 con Open 695 Cred =neus SqlCermrmand C" ; ieees 2 = cmd. Exectute NomQuerq oy; con. Closec>; 5 Update Operation public vofd Update Product CPredasct procerct ) Cons new Sqlloonecti onl strcen); Opened; Crad=cew SqiQormmand C" spUpdate Rocce", con), cred -Coromand Type = Command Type » Stored Rraceeate J Hass the fete Prorkest0, Narre and Pee Sqloxotmetey PaemRedutiD=oe0 Sal rameter Red ucttTh? PKs cend ExecuteNor Quany cS; Precluct, R@duct 155; con. Clesec> cmd. Pavareter: oa } C Pra Roduct3D) - 4 I| Delete Operation wate Slew heir public vetd DeteteReduck (tnt td) £ con = new Sal Connection Gweony 3 can. Open’; Cmd= new SqlCommane (" spDeteteProdeee, con) - Gerona TYPE * Corsemand Tipe: Reacedurt,? creel Bavammetors, Set WHA Iue (4h ecatE OSs Poh) 5 cmd. Execsadke Non Quany cr; con. Closec>; We aha Appiieation Logfc ‘ Ada a meio MVC appifeation to solution 2 demport Reference foc DotoeccessLayey 3-Geate a Ce contolter by Came * RecductsConiatier” Ueing BS ee The) conkig Fite: poblic class DrectucesGontrotier; Controuey BrocuctsCRUD Ab=rew RoductscRUDC>; public Arctionesutt fede) Lict- prods=db »productatfst. Tolistc; ewan View(prodsy 5 4 cam t public. QcktenResatt Dats te OB AD et 2 od = abe prockuctsLecte> angle Cxz> % Reduct: Roauct Pe nets), xetemm View Cproal), is 3 [Ocanpt\Vletes( Hetperbs Gerd) LectionName(" Create") ] public AdiorResutt exeateOrGet¢) u Yetean View OD} Crttep sc] (edtonNarme (Create ")] pablic CotionResutt Create@oPostec) £ F (MedetState IsValid) Recluck product = nee Redecee>; By updaremacet Oproctesct) » ato, Pkt Rocluct (prectuct) ; “ Rediwect To erctors C Indene Ds Uitte Get] Public GotiorMesutt Edtt Cnt tat) Lt Neto, Vee Cd barectucts| Fst. Single Cx o> Reduas 80> “id), % Creeper] pabic ckemResutt El?) i (Model State “As Vaticl) x Preduck precuct= new Redect ys TeypdateModel(pratuct); ale. Update Poduct(broduce 3; yexuan Rede ctToAction('Grelen" CrepGet J (ActiomNamel” Detete”)] pobiic AcionResutr HeleteOn Get Cire td) venage View ib -Produces Lise -Ség teCa=p Product == fd » > [ittipPosey [ectoohamet" Delete J} Walidare@nttorqeryloren} public ActionResute Delete oPest (ire ta 4 DeteteProductRet Dy , RecirectFocttor(ninder>; 3 Stepq! Oa Views fox Yet actions 1 Mew “Yor Tedex -action Nacne ; {odtex “Teeoplate | List. Model class 7 Reduct DataPacsslaqer) 2. View few Details Actian Nome ; Detaiis ‘Yernplatke + (Setafls, Medet class + Precluct (DatnecocssLa yer) B View for Gite Acton Nocme 2 Este Teorplate: Edit Medel class: Padust Datadmesslayer) he View For Delete &ction Name ; Belete Jemplate : Delete Medel ctaas :DecauctMatanecesslayed) Vetous mettads of Bending Foren Data to a Gontrollcy method : v seq model Ketd names os Params Ceontvol "£94 te te Pale feld some) Ex? PpttpRec} poli @ctonResult Geeate (sting Nome decimal Dyce) TRedact product = e200 Prochact o> - Procluct Nate = Sram Prodact. Rice = Ree; Alb. Pct ccteactredaack 5, Yorn ReAtrecklo@ctoenc orden") ; % 2. Use a tedel object to bid the values, Ext Trtephst } pobie BorenResatt Create CReduct protect) Ae. Bick Prectesct (predeect) 5 petty Reclvsct Octo ("Inclex") % 2. Use acter Cotlection okie keys ordi Wheiv values as “Yolues" fs dictionacty wim fied names os ez: CHtepest) public PeteonResutt Create Cfaxen Gatection tren Covection’) Reduct product mei Reduct 0; product Name = frm Cottection(™ Name"). Tostang (); precdact-Rece = Comet. TeDecimal hen Gutectianl Pree); al eaet Precletct (prediact ° ket Recltcecttonction Index") ; 4 db Updote Model method Ext ChttpRstJ public @otion Result Greater?) Cetuce product=sep Redeert > - Update Model product); lb. @xtet ProduceCprocleser) 5 Yeturo rect Action Index" )y % 5. Tq Update Made! method, which update the Medel wher meclet state ts Voli. Ez! CHetpPost] pubic Oction Result Creater ) tec Modtetstate. [sVatia > Rodect prcderets mew Product ¢ > “Tx cq UpdeteMecte | Cpredunt> ¥ Alb. eedProtauck(preduct}; vere, Reclivecifoaetion Cinder”); Moe SDeta Gonotations fo MVC Dota ametations ove atitbutes, used otto Ihe model Aieide to control thei bebautouy ond furcsponalitay Oy atifoutes &n WET Framework ate dewtued from +he Ubrory System. Otefoute - +tousevest “the data annetations ave corrfiquwed uncer he Library Systern- Component Medele Data @rnotations + f Tee onnatations ave fm MVC ae classthied tnto 3types. t Depa Orretations 9. Gaze Qonotations 2, Validation Eronetetfoms Display Anrotations: “Woe ae 4 2 clfeplay annotations ave used to specifiy the unctfona lity of model elds t Desplay Templates (i List, Details, Delete 7 “hese annotations Wl effeet ne ckeplay templated tHetpers lke 2} Htro|. Display >) © Fite) -Desplayforc) © Hiro |. DoeprayferMedele > mine dlfsploy annotations ave - DésplayNome - DEplaryformat — ScoffotdColionn DksplayNerne: dete Used to spectiy Aiienduy Diepieuy PAP forthe mate fietds eu [ptaplayg Name c(h Predactd pd] public Wot Product DL GetS gery eo Toad Qame =" Product Reed] public doulbhe? Reece Lactiset} Display feumat ! Se represent rede ove APO Aata. hh & used te o meter tee ld Loicy- Comuney pao Lordz - Shot Bare Lor DY- Leng Bate LOi1% — Shove tere 7 Sort} = Long Teme an ateftbute that apecthy's \yow clerbar ed ard formatted bY asp.net clqnannce ect vortous data forme Sting foe Ce Coenen iret Retterronstong= “C0: 3} ")} ep c ce fgets sets} SceaffidGluren? H vepresents em attribute that specy's wobether the wmectet Held WY wse the scafford template, which uses the tomplated helpers Vie d 2st). Ditptacyfarmedet ¢ ) De Roni. Edttovfovmoctele ) abe scaffold templates that oxe using “these -erplated helpers wit nok cttaplag-the model fiers Th tt is set to wotean “fatse”, © cat feud Cason False} pabiic fre Precdect 8B £qct3 setj} Cie Oorotations / he edit ametations are atafbuies that cam contrel meclet Fietde and testiick “them to a specihic datatype Ore Input value So that heey cannot 4et the value anything otter than specified. ex [aterType(DataType-Passwcorel) J public ating, Passurord { qcts set} (CBatattype( Datarype- Dated] pebtic Datetime Manudactured SqctiseB ReadOnly: de speety's “the whether the property ts beund to Ready oy Read Write Ae well nek allew to Sek a value when speedy te beolean” tue | ext CRead@ntyC cueyy pubic tne Product DD Lagat; sobs} eo ¢. aw Nalidatfons fy MVC! Valtdations ave vequived to ensue that contradicts, Cor) Unoutthowaed dat Bs Mot Yet Stored Pto the “datohoes” SPnet GS thtreduced “c cast flation’ ps ¢ used Sutobstiusive validation tobich, Yequived query sc®pe resouvees Mappen: MVC ineteducea asnctations for validations which ave clefinect urdes “SystermWeb.Mve" and "System. ComjonentMadel’ “iL Vatdation amtotatfons are atuibutes deftned for model dgeide and validation messages ate di S * trod helpers’ Ceontrals> “ Se 4 “Sg “@HIML: Validation Messagelorc y" Wee enable unabstustve validation set the Lucsing ~ Welo« Cork tile. AoppSettrge> . cada lee ys Manat strusive JaveSearprGrabled " velucsittrue' js 2 lappSettings > Walidation Asnetations wo Myc! 1. Requived 2 Sthoglengih B. Com pare ie Range s qt ay Expresston, 6. Remote U Required: oa bute that specifies a clatafield Tk ve presents an ani aanit be pull” he he Held reuse be potectrd with value Ex! CRequived (enor snesage = "userid yequired ")) Public shin g uasev?d Lats sets ¢ 2. StingLengths de specifics he minimum ond maximum | aye PAGED o chavacters allowed [0 the dataferd. a: . CSuingLengié (0, minimumlengin= ¢ Enoy Mesage» a “userfA qo 10 charact as] patric sting usatald getiset 5) 2. Corspavet die KEPeSEts an atitibate that ts Used te compase tra cata field withthe valle fm curother values ste value Ge vereaos beolear atse" AR both ave cot equal Sygokrt! Ceorepane('Rassitor"; EnerMesaage oRasseeoud mismatch] poi string Cookers ssicoxcd z Fett af Range * ac specifies the Sutmee Yong? constants for the Valu tn detakeld and ensures that ispat vette fatse within opecttted range yoke: 7 . (Range (18.25 ematestage = @qe Ts 15 to15 eoly"3"] pubite foe? eget gets Sew} 5s. Kequdar Capresston: de Specifies tat the datarheld values fo 45D. net alyoarnic classes must match twofth The specitred tee vegular— expresston- Ex! (Requtexapression(@ “C2 =- * TA-2 Dw hs1545 Cre Message "Password @toIs chavs with atlas one public sbing Password AL getiser. 3 3 Case 4) 6. Remote! PCS ietteduces, new vernote validattons that Provicles, an axtibabe Using {eery valicetion Plag’n order to validate vthe watne present to datattetel. dk ts stenttar tog custom Validator which uses a Sewer Side Validation Facction Ex : 1. Create Q Tew database Tabl= with fields and ates Vales usefacPh} varcha usaNarpe — Varchax 2 By using entity clata emedet bind tne table with your appication YusersDataMedel. ednvx" —tholuses-cs ~ MwveDeclactsDbemittescslcontext} 2. Create a mew Contour bi name “UusersContrettey" tising, Mveredlacts-Mieciet; 4 os public “clas UsersCentrottty + Gntroter pveDrederctsdbentetes, b= new Myc Praclucts Mbentitiesr 5 pabtre sonkesextt Ssbser 2 iaken (Sting userf) vetean Wot bdb. thusas. Any( x=) ¥-Usevel= = userid) dsonkequest Behavicns, tteGatd § 4 public PetorResutt Index) | Creat Uew Tbe Intex dete Veer g ys Name: Index L. Goto “tluser cs" Ternplate? Cyeate usiog System.Web-Mve Modet :tbluser (ma public partial olass thluseys CRercte(" s'Tc © tases! Ys Userid Taken", “users”, ErorMessages " Osered Taken ~ fA eas Tyy Bnottan’ public Shing Userte {ets Set 5] q ren) Arction Setectey & Myc: Action Setectexs ave attiibutes cleftned fy controuey action mettad fm order te corticl theiy behavieux. these ave defined by System, Web. Myc “Hthe Corpmaniiy Used action Seleators axe - CActionNarne] >. CAcceprVearbs 3 %. (Nen@ctton] 1. [Actoename]; Th vepresents an atuibutes thot tS Used to specify on elias came yr Controtier action Ear (Octionnamel "Create J) public OctionResutk GeateOnGetC > yetuan Viewl; ‘ actpeverbs]] ¢ af as an attyibute that speerfies which Http Verbs, fam action nether! Wil respend to fe Gets [Ast Put sletete etc Cer (peceptNerbs Thepverbs-Ros} public ectionR=alt Geatec ) on Redirect tA choo Index") ; » [Nen@ctom]: * ge vepvesents ao artabyte that [s used to iadtcote “thar t Controller methods ave mot an actor methed can't invoked boy Ort request - OU nection public Stvng username (String urame>d yetaan "Hetlol" + uname ; y v Pretion Fters 7 MVC: & Oxtion ftiters ave atetbutes dedined foro conholtes axeTes cactOo> muthod. OC action Huters are used ty cantrol the functor of am actor method ey Controed class which cludes authotfaation , autho. & t da enton Hern te ore een! tor he hee “ Gy ctionfitererti bute te fs tho base class de-fned vancley * Syster- wWebsMuc Some of the caremonley used actton cliers ave |. Vaifidategnpat 2. AhtdActionOnty 3. Chatpat Cache Gp Handle Exroy 6: Require AtEps 6. Exerrovise 4. Qitew Prrong ou 8. Validate Onttharger (Token etc --- Vatelatednput : de represents an extfbute tat tS used to mark ated Je Controls caution methods whase thpat muse be valid: post quentes evoss stir sexipting attark and wit mot allow to rorm controls: You an atlew that by setting that bootwars’ false” , ox 4 \. Create anew contvattey by Marne “Deno (ontialler | 2. Odd favowing metheds CHtepGer J public ViewResutk Comments > SetUAn View (5 oe IO BD ; Se eo} vee Che pPosty Wy as! a [Validate dnput ratseS) ( * putsic Shing Comenents Ging Comments) oe { ra Yet "Yous Cammnunts t "+ CormmmentS 5 fae 4 2 es 1 OF yee Se 2. Odd Vee toy corpments action org peso Ge oe Name + Comenents _ Template! Eropty Gotthout model} Gonrnants . cshtros} Your Comments . Zinpat type ene" vattie> “Past Corners’ “f> \forn> Chik @ctiorOotys Te vepSetents an edttbute ie used to frdfealt that an action mitted Should be cated Orly as chile Recipe asd can't be fhuatad Bhrecttey by Ol Yequase- Cu 1 Create a nito datahase table. « telRoducts” PeductID tt Nome Vaxchar (22> Bice double Pocts vorchas 2. dd vecovds with Photo etd asiog tty fmage Rate ev) Photas| motte. f : a ~ 3.Goto MVC application, 4 Odd anew foider by mace" Photos 5. Ord Product fmages tito he toutes 8: Gotm Models ard add “ebo.wet €ntieg Data Model” ox eos table ReductsDetuModel .eclnx Medel class + thiPaduct Cement Class ; Reducts Content DbSet + kbtDeducts . @dd omens controuey by name * Reducks Gotrotey * using MucbernoMadels + peble class PodaetsCantictter s Canketley Detects Contert dbenew RedecesContertt YS pubsic A@ctiomReaatl Yndexc> yetuin View Cab. HolProdcacts. TELest 055 Told con Onteq] public Partial ierrReatt Roto Typec > { yeeesn Dartfall iteuoe + y FS B Oe View toy Rotstype Oetfon Nome: Rotetype Teonplate ! Crnpty Mose! class : tht Proctuek (Motels) Bi. Create as Perttal Poorstype- cshten! Goedel Imuracotled YvcDdemo-Models.thtRoduct ? usttib: “100 a\tas heaght= "loo" |S etd ctable lode =‘) ced ctas Peodeok BD Medel. Product PD zd dReduck Name leds ced QMadel. Name cled's cltyS ays cea Poduct Pico citds Zkas @ Medel. Pico cled > <\by> eltables Zlkas Zits C\tables 9. Geld View for dnctex Action Nome 7 Index Ternplore , Erpty Medel class < Ubf Product (Modders) fedex. esbtrot @vedel TGhameveble cMvcDemo. Mod, lS. LN Precces char Predects Index zihss @Hoveach (vax ther %& Meader) 4 \\ @terat- Paxttal ( “Prototype Peery) ic Hirt: RendePavtiat (« Petctagne® feern) + % 4 Net! Hert Partfat uses a Yourd tifp and vetuting a Stef aothat Ths value con be stored fra Vakable acd accessed for any mthed, Htrnt. Reodey Ravifat returns Vote othing’)) and divecttig Witte “he cutpat to response. S that tes faster when compare to HE emt. Partiat No QuepetCocbe! » 4b vepresents a0 ottifbuke tbat f used to mark an intro Whose autpab wit he cache.harfs ft uses — he potiles and makes the data available t the ae enor $0 Tae Pee Ps frequentiy vetuuted theo cache we * a th estu access fromm the cache trstsad oF communicating ih Sivex . Ex Go Web- contig aod Cxeake coche pofites. (- : esyscernweb> < caching > a erableCutputCache xen View Gb. tbiReducts -ToLstco); 2. Odd View ~by Index @ction Name: index Template Empty (eotthouk model) fodex. esberss| DateTime. ous Testing? > HardieEver : Te vepresents an attibube te used to bardle an Cxceptian ke thimen ey om ache metinad, fr vequives go that 8% céspiatys Yettows Cenk Sexes sexe castors exoy trode Set to on” a ‘firerdtey enor pages fostead of LYetlow death Aeot 2. Blue cleats 3. Wes of death ups TMS) Sz% |.Cyeate a maw Gmtoltey catied “AroxControltex ” public class ExvovGmtrattcy : Comtiotter 4 Public OcttomResast Notfourde ) £ Yeruan ViewC); 4 2, Adel Leew for "Netfosnd ' Action etfound. csbtrest chd Action You Rexested Net found 3. Gato “shared 4oder fo Views and add o tea Vie by name * Grov.cshtm)" |usetd | Name AN emai . Uso \ ie 1 = ¥ a wv \ 4 —\— aivoler ¥ Dalen FD. Create a Mew controltry toy Cae sQamio”) J [Outhowe (Roles = rolex 7 Conte ley pattie dass ErienfnCoo! public ActonReautk aodexe > q yetean View 05 Pltew@reny U8: tt vepactents ar oc skip authenrfeat oo d ox bes the controler rebel that the cunthorizattoo acton to ound process. Ex: Cote nonymeons’} 4A. i? awe os public @ctonResuth Regesterc) “ee xX sf Nyeke Ulewory 5 oe & % 7 Regquivettteps: & Sp tk veparents an atttbute that forces an unsecured Hep Sequast to be resent vet Heps request “This requires access 10 domains confiqused und Https Protocol: at PRequice Hetps] paliic ActionResatt Navesh Priebsitec.) 4 : vetuin Redirect C" bet ps: |) localboselmet “Ys Validate nttinger4 Token, dt repaerents an atutoute amat is used to prevent tecgery of a veqenest that fs Te coi Mot alow cir Ne application to post data foto tn qeuy applications axe petty SB chepdose) [Valfclate Ont thongerqTotto] publ ActorResath edtt € Proceser product Xap. UpdateProduct(peauct), yernin Redivect To@ctian ("Jodex"); % pw’ Coston Fetews fo mvcy ROAR Tons fox CRUD 4 alto ehose ne te) Extto fitters to MVC are tenplemantecl for ocion filer " ettun, which provides meinade thar aan be aveniden and avews to create Custer filters “the methede axe # On@ctionExecuuked (5, > nA ctionexe cutting ¢ Ss » CoResuttCreautede ) # Co Rest Execanttngc) ea: Lede a new folder by Fame @utom-—fFiters” 5.eck a new class file tito Sis foictey TWrorkConteotler AckfonS.c asin Rptern, Web-Mves using System. 10; pabte class. Vvack Contiottey @ctfong + Octlontiterattfoute public Static wie Coearchace Fite (string ee) File Qppendoutert( AtpGnbere: Gavent - Server, MepPatts (nr | Content| brace. tak) sj pubic evenfide vot On Exton Enecutting (Action Erecting Oreo Siteectext string str=«\n'; fitta Gnteut . ActiomDesniptey « Contrettey Desoliptry « Gntictter Name} _ Wy “> Hitter Gotat. ActiooNescuiptor. Actinwiames 4 > op “Executed ont "++ DateTime. Nous TaString C>+ “pty = 5 Create Trace Fite cSt; B. Gots 'AeckectsGootiotter a rs WT Sed OBEY Hoty castors fi ttey OG Jack GusterrFitteys CRackGonhounections} pete dass PeductsControlter; Gontrettey ~~atéons-> FfteResunt tragedndexc ) Ye8> Fle Cn | Content | wy, ; y tent | trace. te") Masfeatem and Burching s i Mictfecation fe the Proecss of seducting tthe sie of Favascip: and ess fites t oder to improve the load tine , PSP. WET GS Provides Severat reves FE cation Pleg tos wheeb alleas venfous code opelmisaticn to scvipts ov Css “they Vernove Upnecessary white grace, tine byeakc aed Sox tenting vetabie names into one charcttey. Ca: 1 Odd a new seyle cect foi Gentent bidey by Dame “Headingsecss" sheadengs baaleqroud ~coloy ved; eclovs white, 4 teu ralegnhcentay 2 Iestax miniffarten toels ov Plugen —TealeMenu ~ Upeate ard Extendiong ~ Search online fey “Web Gsseartatst ~ Deunload ond fasbasr 2. Right click on “Headings. cos land select “Minty” Headings. ir css Baccitng 4b Fe the pecess of creating a bundle of cog and ee of requsits. foocey Ries oncans Feqesk and thak car Sopose page faa perfnmane ovveance wfie oder to reduce he 00. -feeses tltep Ex! \ Create Fatiowing Style sheets aed ~ headengs.css — Paveugpaphs- css 2. Et Opp-Stare-e BucsieConteg. css Lislog System eb- Optimisation: Public class BundleCanfeg 4 pablte static usted Reston Bimttes (Bundie tection burda) add mt content file, lpundies. Oda Chews StyteBurdte(ts| Entent] Dens") - Yrctedel 4] Gontene |! handling’. ess Yno\ Content lparagwaphs-css YS 5 He You con access the bundle from any Ven (ndex-cshtral Styles. Render | Contert[Lemo') (Ff tS Scxtpks then We @Saipts Reedey (| Content [Demed tSstrap! + ot & one of the largest Yepesitory of css ord dove Scape « 4 provides tompletes thatucan frepument in eyored apps » AD-NET G5 orwatds beststrap Ps tetlhcat lato web Qpplteations dy Wie Farry alee &) Mve app ©) SPH Ex OEM, of \. Viste GetReskStiap offemal web ste sco aa 2. Goto CSS or Javascript category we we 3. Select any Cxample Uke buttons manus fowns-- Anes wll provide qou ESS ame ATUL cade. 3. Copd the cas excle into aces He to qouy website and HTML cacle Inte ou Vlews. B. Trapent the Fouewing fies toto qour cebtert View ~—beotstrap. min. ¢ss fhe —beetstrap mings aster Leregcabs ! 1 master layout & nothing fur master page Used Pry web apptreations £0 qveq Uniforms appearence and functonattty foe a pages . Vien wth extenston “. cshene 2. 0 raster taut & ales o earpenant of master (ayout & RerdeBedyc)") B.the key which specihes the location that indicates where the chad Page content uitt be yenderecl. Jp New can assign masies layout fo any enlisting view hy “sing the attrbabe" Layout fadex. esbtrn¢ @ ee =a] Viecos | shaved | Suemaster. cabten|”y BH you want to set the mastey lagout as the defowte mascer leujout foc the oppifcatian thie contig eta the Layout attibate in" ViewStart, eshte © C Views —+ Sharad > Meoshate eshtm]) eu: \. Goto Views —& shared yictey 2. Right Click ond Seleet ALG caw View Newpe, teMastey Termpiaie : Crepty fotiheut adel) Cl Use Master Cayout uncheck, Sit-Master, csbtrnl a thockey & ckable width= "taa"s cts style= “back grourd ~ colors ted; Coley: white teyk-align? Centey" > ZtAd @ Htorle SctionLink CY Home, “Hlorme”) © Htenh Actionlink ("ober t, Wbecees) ety height "goa" 2hcd calapan =! C@ PerdeBady 9 < ites Wo cies chy stifle 2" background: coley’ vedt calor: white} text-align: cent en" Ls Ct colspan= 434s £ copy sC2py Raghe rol < lel Jikes éttables Zl becky > thts. 7 We MWe Helpers ard Ajax relpers. PY Mve efor Helpers: ? stletpers are methods “that dnannt cally wade ® ftrn/ contele MVC Supports titemt heipess and @fox He lpexs Ajax tdpers - fo

    You might also like