Lub npe ntawm lub neej ntawd ViewStart nplooj ntawv hauv ASP NET MVC yog dab tsi?
Lub npe ntawm lub neej ntawd ViewStart nplooj ntawv hauv ASP NET MVC yog dab tsi?

Video: Lub npe ntawm lub neej ntawd ViewStart nplooj ntawv hauv ASP NET MVC yog dab tsi?

Video: Lub npe ntawm lub neej ntawd ViewStart nplooj ntawv hauv ASP NET MVC yog dab tsi?
Video: Tshuaj theem vim li cas thiaj tau nqi ?/ Siv kho mob dab tsi?/paris polyphylla use for? 2024, Hlis ntuj nqeg
Anonim

Dab tsi yog kev siv ntawm SaibStart hauv ASP . NET MVC ? Teb: Hauv ua ntej template ntawm ASP . NET MVC , peb tau _ViewStart . cshtml ua nplooj uas yog siv los yuav luag zoo ib yam li MasterPage hauv ASP . NET Web Form lossis zoo li tus qauv layout.

Ntxiv mus, Viewstart nplooj ntawv hauv MVC yog dab tsi?

_Viewstart Page hauv ASP. NET MVC 3 cshtml nplooj yog qhov tshwj xeeb saib nplooj muaj cov nqe lus tshaj tawm kom suav nrog Layout nplooj . Es tsis txhob tshaj tawm qhov Layout nplooj hauv txhua qhov kev pom nplooj , peb tuaj yeem siv tau _ViewStart nplooj ntawv.

Ib tug kuj yuav nug, dab tsi yog nplooj ntawv layout hauv MVC? Kev tshaj tawm. layouts yog siv rau hauv MVC los muab qhov zoo sib xws thiab kev xav ntawm txhua tus nplooj ntawv ntawm peb daim ntawv thov. Nws yog tib yam li txhais tus Xib Hwb Nplooj ntawv tab sis MVC muab qee qhov kev ua haujlwm ntxiv.

Ib yam li ntawd, nws tau nug, _ViewStart yog dab tsi?

Pib nrog ASP. NET MVC 3 Beta tso tawm, tam sim no koj tuaj yeem ntxiv cov ntaub ntawv hu ua _ViewStart . cshtml (or _ViewStart . Cov _ViewStart cov ntaub ntawv tuaj yeem siv los txheeb xyuas cov lej saib uas koj xav ua thaum pib ntawm txhua qhov View's rendering. Piv txwv li, peb tuaj yeem sau cov lej hauv peb _ViewStart.

Peb puas tuaj yeem muaj ntau qhov kev teeb tsa hauv MVC?

Teb - Yog, peb tuaj yeem siv ntau qhov layout hauv ASP. Net MVC daim ntawv thov. Los ntawm lub neej ntawd, Visual Studio ntxiv a Layout nplooj ntawv nyob rau hauv ib tug sib koom folder uas ua tau siv los ntawm lwm cov nplooj ntawv Saib yog tias xav tau. Qee zaum, peb tuaj yeem muaj qhov yuav tsum tau siv ntau yam qhia layout paj in MVC daim ntawv thov.

Pom zoo: