ASP.NET MVC 2ãã¬ãŒã ã¯ãŒã¯ã®æçµãªãªãŒã¹ãã4ãæ以äžãçµéããéçºããŒã ã¯ã
ASP.NET MVC 3ã®æåã®äºåããŒãžã§ã³ãçºè¡šã§ããããšãå¬ããæã
ãŸã ã çºè¡šãšããŠã³ããŒãã®ãªã³ã¯
ã¯ãã¡ãã«ãããŸã ã
ãã®èšäºã§ã¯ããã¬ãŒã ã¯ãŒã¯ã®æ°ããããŒãžã§ã³ã§çºçããé©æ°ãšå€æŽã®æŠèŠã説æããŸãã
.NET Framework 4.0ã®äºææ§ãšãµããŒã
åã®ããŒãžã§ã³ãšã¯ç°ãªããASP.NET MVC 3ã¯
.NET Frameworkã® 4çªç®ã®ããŒãžã§ã³ã®ã¿ããµããŒãã
ãŸã ã ããã«ã
Visual Studioãžã®çµ±åã®ããã®éçºè
ã³ã³ããŒãã³ãã¯ã
Visual Studio 2010ããã³
Visual Web Developer Express 2010ã§ã®ã¿ãµããŒããããŠããŸãã
ASP.NET MVC 3ãã¬ãŒã ã¯ãŒã¯ã¯ãASP.NET MVC 2ãšäžç·ã«ã€ã³ã¹ããŒã«ã§ããäºãã«å¥ã
ã«äœ¿çšã§ããŸãã
åã®ããŒãžã§ã³ããASP.NET MVC 3ãžã®ã¢ããã°ã¬ãŒã
ãã¬ãŒã ã¯ãŒã¯ã®ä»¥åã®ããŒãžã§ã³ããæ°ããæ«å®çã«ãããžã§ã¯ããæŽæ°ããæãç°¡åãªæ¹æ³ã¯ãæ°ããMVC 3ãããžã§ã¯ããäœæããå€ããããžã§ã¯ãã®ãã¹ãŠã®ã³ã³ããŒãã³ãïŒã³ã³ãããŒã©ãŒããã¥ãŒãè£å©ãã¡ã€ã«ïŒãããã«è»¢éããããšã§ãã
ASP.NET MVC 2ã«åºã¥ããããžã§ã¯ããASP.NET MVC 3 Preview 1ã®æ°ããããŒãžã§ã³ã«æåã§ã¢ããã°ã¬ãŒãããã«ã¯ã以äžãå®è¡ããå¿
èŠããããŸãã
- ãã¹ãŠã®web.configãã¡ã€ã«ã§ã System.Web.MvcãVersion = 2.0.0.0ã®è¡ãSystem.Web.MvcãVersion = 3.0.0.0ã®è¡ã«çœ®ãæããŸãã
- ãããžã§ã¯ããã2çªç®ã®ããŒãžã§ã³ã®System.Web.Mvcã¢ã»ã³ããªãžã®ãªã³ã¯ãåé€ãã3çªç®ã®ããŒãžã§ã³ã®ãã¬ãŒã ã¯ãŒã¯ã®ã¢ã»ã³ããªãè¿œå ããŸãã
- .csprojãããžã§ã¯ããã¡ã€ã«ãç·šéãã ProjectTypeGuidsèŠçŽ ã®å€ã{F85E285D-A4E0-4152-9332-AB1D724D3325}ãã{E53F8FEA-EAE0-44A6-8774-FFD645390401}ã«çœ®ãæããŸã ã
- ãããžã§ã¯ããASP.NET MVC 2çšã«ã³ã³ãã€ã«ãããã¢ã»ã³ããªãåç
§ããå Žåãweb.configãã¡ã€ã«ã®configuatonã»ã¯ã·ã§ã³ã«æ¬¡ã®ã³ãŒããè¿œå ããŸãã
ASP.NET MVC 3ãã¬ãã¥ãŒ1ã®é©æ°
ãã®ãã¬ãŒã ã¯ãŒã¯ã®æ°ããããŒãžã§ã³ã«ã¯ãå€ãã®éèŠãªé©æ°ããããŸãã
Razor View Engineã®ãµããŒã
ãã®ããŒãžã§ã³ãããASP.NET MVCã¯æ°ãã
Razorãã¥ãŒããŒã¯ã¢ããæ§æã®ãµããŒããå°å
¥ããŸãã å°ãåãŸã§ãRazorã¯
WebMartix Webéçº
ããŒã«ãããžã§ã¯ãã®ãã¥ãŒã®åºæ¬æ§æãšããŠ
å°å
¥ãããŸããã Razorã¯ãMVCã¢ããªã±ãŒã·ã§ã³ã®éçºã«äœ¿çšã§ããããã«ãªããŸããã
Razorã¯ãHTMLã³ãŒããæäœããããã«æé©åãããæ§æã§ãã ASP.NET Webãã©ãŒã ãšã³ãžã³ã¯ã³ã³ãããŒã«ã«éç¹ã眮ããŠããããã®ã³ãŒãã¯HTMLã³ãŒãéã§ãªãŒããŒããŒããããŠããããã«èŠããŸãã äžæ¹ãRazorã¯ããã¬ãŒã³ããŒã·ã§ã³ããžãã¯ãHTMLã³ãŒãã«ç°¡æœã«çµ±åãããéåžžã«æé©åããããœãªã¥ãŒã·ã§ã³ãæäŸããŸãã
äŸãèããŠã¿ãŸãããã 以äžã¯ãå€ããã¬ãŒã³ããŒã·ã§ã³ãšã³ãžã³ïŒå·ŠïŒãšæ°ããRazorãšã³ãžã³ïŒå³ïŒã䜿çšããŠæ§ç¯ããããã©ãŒã ã§ãã
ç®ãåŒãRazorã®äž»ãªéãã¯ãééã»ããã<%%>ãããªãããšã§ãã å®éã
@ usingã°ã«ãŒãå
æ§æã«ãçµäºèŠçŽ ã¯å«ãŸãããæ«å°Ÿã®ã}ãæåã®ã¿ã§è¡šãããŸãã ãããšWebFormsããŒãžã§ã³ã§ã<ïŒ
}ïŒ
>ããèšè¿°ããå¿
èŠæ§ãæ¯èŒãããšãRazoréçºã®äž»ãªçŠç¹ãäœã§ããããã³ãŒããšãã®ç°¡æœããæžããããšã«ããéçºè
ã®çç£æ§ãç解ã§ããŸãã
ç¹ã«ãRazorã®äŸ¿å©ãã¯ãã³ãŒãå
ã«ãã©ã³ããäœæãããšãã«çŸããŸããããšãã°ãWebFormsãšRazorã§ã®ã³ãŒãã®äŸã次ã«ç€ºããŸãã
èŠçŽ ã<%%>ãã䜿çšããŠããŒã¯ã¢ããããæ¡ä»¶ãå
æããå¿
èŠããããã©ã³ããåéããã®ã¯éåžžã«é¢åã§ãã äžæ¹ãRazorã䜿çšãããšãã®ããŒã¯ã¢ãããã©ã³ãã®èª¿åãèŠãŠãã ããã ãµã€ã¯ã«ãªã©ãä»ã®å€ãã®ã±ãŒã¹ã§ãåãå©ç¹ãå®èšŒãããŠããŸãã
Razorã«ã¯ãéå§æåãšçµäºæåã®æ§æãç°ãªãã ãã§ãªããéãããããŸãã ãã®ãããããšãã°ã以äžã¯ããŒãžãæ§æããWebFromsã®ã¿ã€ãã«ãèšå®ããããã®ã³ãŒãã§ãã
åãã³ãŒãã§ãããRazorã¹ã¿ã€ã«ã®ãã®ã以äžã«ç€ºããŸãã
ã¹ã³ããã»ã¬ã¹ãªãŒã®èšäºã®
ãã®ç¿»èš³ãããRazoræåºãšã³ãžã³ã«é¢ãã詳现ã倧å¹
ã«åŠã¶ããšãã§ããŸãã
Visual Studioã§ã®è€æ°ã®ãã¬ãŒã³ããŒã·ã§ã³ãšã³ãžã³ã®ãµããŒã
æ°ããRazorãã¬ãŒã³ããŒã·ã§ã³ãšã³ãžã³ã®äœæã«ãããMVCéçºè
ã¯ãéçºè
ã䜿çšããã¡ã«ããºã ãéžæã§ããããã«ãªããŸããã Visual StudioããŒã«ã¯ãæ°ãããã¥ãŒãäœæãããšãã«ãã¥ãŒãšã³ãžã³ãéžæã§ããããã«ãªããŸããã
Viewããã³ViewModelã®åçããããã£
MVC3ã¯.NET 4.0ã®ã¿ããµããŒãããŠããããããã¬ãŒã ã¯ãŒã¯éçºè
ã¯ASP.NET MVCã®æ°ããããŒãžã§ã³ã®.NETãå©çšããããšãã§ããŸããã
ãããã®å©ç¹ã®1ã€ã¯ãæ°ããåçåã®ãµããŒãã§ãã MVC 3ã§ã¯ãããªãã¿ã®
ViewDataããããã£ã¯ã
Viewãš
ViewModelã® 2ã€ã®åçå®è£
ãšããŠè¡šãããŸãã ããã«ããã次ã®ã³ãŒãã®ä»£ããã«äœ¿çšã§ããŸãã
ViewData ["ã¿ã€ãã«"] = "ã¿ã€ãã«"; </ em
ViewData ["Message"] = "Hello WorldïŒ";
å€ãç°ãªãæ¹æ³ã§åæåããŸãã
ViewModel.Title = "ã¿ã€ãã«";
ViewModel.Message = "Hello WorldïŒ";
ãªããžã§ã¯ãã®æ¡åŒµæ©èœãå³åº§ã«äœæããæ©èœã¯ã.NET 4.0ã®åçãªåããããã£ã§ãã ãã®å Žåããã¥ãŒã®ã³ã³ããã¹ãå
ã®ãã£ãŒã«ããžã®ã¢ã¯ã»ã¹ã¯ç°¡ç¥åãããŸãã
<h2> View.Title </ h2>
<p> View.Message </ p>
äŸåæ§æ³šå
¥ã®ãµããŒã
MVC 3ã§ã¯ãéçºè
ã¯ãã¬ãŒã ã¯ãŒã¯ãæ¡åŒµããå¯èœæ§ãé«ããç¬èªã®å®è£
ã«é Œãããšãªããç®±ããåºããŠã³ãŒããæ¿å
¥ããããã®ãµããŒããè¿œå ããŸããã
ASP.NET MVC 3 Preview 1ã¯ã次ã®å Žæã«æ³šå
¥ããæ©èœãè¿œå ããŸãã
- ã³ã³ãããŒã©ãŒãã¡ã¯ããªãŒã®äœæã
- ã³ã³ãããŒã©ãŒã®äœæã
- Webãã©ãŒã ãšRazorã®äž¡æ¹ã®ãã¬ãŒã³ããŒã·ã§ã³ãšã³ãžã³ã®äœæ¥ã®ããŸããŸãªæ®µéã
- ã¢ã¯ã·ã§ã³ãã£ã«ã¿ãŒ
ã€ã³ãžã§ã¯ã·ã§ã³ãè¡ãã«ã¯ãéçºè
ã¯IServiceLocatorã€ã³ã¿ãŒãã§ã€ã¹ã®å®è£
ã決å®ããå¿
èŠããããŸãã
ãã®åŸãéçºè
ã¯ã次ã®ããã«å®çŸ©ãããŠããã°ããŒãã«éçã¯ã©ã¹ã䜿çšããŠæ°ããã€ã³ã¹ã¿ã³ã¹ãç»é²ããŸãã
éçºè
ã¯
SetCurrentã¡ãœãããåŒã³åºããŠã
IServiceLocatorã®æ°ããå®è£
ãèšå®ããŸãã
æ°ããå®è£
ãè¿œå ãããšãASP.NET MVC 3ãšã³ãžã³ã¯ããã次ã®ç®çã§äœ¿çšããŸãã
- ã³ã³ãããŒã©ãŒãã¡ã¯ããªãšã³ã³ãããŒã©ãŒèªäœã®ã€ã³ã¹ã¿ã³ã¹åã
- ãã¬ãŒã³ããŒã·ã§ã³ãšã³ãžã³ããã³ãã¬ãŒã³ããŒã·ã§ã³ããŒãžèªäœã®ã€ã³ã¹ã¿ã³ã¹åã
- ã¢ã¯ã·ã§ã³ãã£ã«ã¿ãŒãã€ã³ã¹ã¿ã³ã¹åããŸãã
ASP.NET MVC 3ã®æ¬¡ã®ããŒãžã§ã³ã¯ãè¿œå ã®ã³ãŒãã€ã³ãžã§ã¯ã·ã§ã³æ©èœãæäŸããŸãã
- ã¢ãã«ãã€ã³ããŒã¡ã«ããºã ã®å Žåã
- å€ã®ãããã€ããŒïŒå€ãããã€ããŒïŒ;
- æ€èšŒãããã€ããŒåãã
- ã¢ãã«ã¡ã¿ããŒã¿ãããã€ããŒçšã
æšæºã®ASP.NET MVCã¡ã«ããºã ã®åäœã«ãããã³ãŒãã€ã³ãžã§ã¯ã·ã§ã³ãµããŒãã®å°å
¥ã«ã次ã®å€æŽãå°å
¥ãããŸããã
- ControllerBuilder.GetControllerFactoryã¯æåã«IServiceLocatorã®æ¢åã®å®è£
ã«ã¢ã¯ã»ã¹ããå®è£
ããªãå Žåã«ã®ã¿ãã³ã³ãããŒã©ãŒãã¡ã¯ããªãäœæããããã®å€ãã¡ã«ããºã ã䜿çšããŸãã
- ã³ã³ãããŒã©ãäœæãããšãã DefaultControllerFactoryã¯æåã«IServiceLocatorã®æ¢åã®å®è£
ãåç
§ããå®è£
ããªãå Žåã«ã®ã¿ãã³ã³ãããŒã©ãäœæããããã®å€ãã¡ã«ããºã ã䜿çšããŸãã
- é¢æ°DefaultControllerFactory.ReleaseController-ã³ã³ãããŒã©ãŒã®ãªãªãŒã¹-ã¯ã IServiceLocatorã®å®è£
ãä»ããŠã®ã¿è¡ãããå®è£
ããªãå Žåã¯ãç¹å¥ãªã€ã³ã¿ãŒãã§ãŒã¹IMvcServiceLocatorããã®ããã©ã«ãå®è£
ã䜿çšãããŸãã
- 以åã®ããã«ViewEngineCollectionã䜿çšãããšããã¥ãŒãšã³ãžã³ã®ã³ã¬ã¯ã·ã§ã³ãè¿œå ã§ããŸãããMVC 3ã§ã¯ããã«å ããŠããã®ã³ã¬ã¯ã·ã§ã³ã«ã¯IServiceLocatorã®å®è£
ã§ç»é²ããããã¹ãŠã®ãã¥ãŒãšã³ãžã³ãå®è³ªçã«å«ãŸããŸãã ããã¯ã¡ãœããåŒã³åºããæå³ããŸãã FindViewãŸãã¯ã FindPartialViewã¯ã IServiceLocatorå®è£
ã䜿çšããŠæåã§è¿œå ãŸãã¯å®çŸ©ãããäžè¬åãããå€ãè¿ããŸãã
- IServiceLocatorå®è£
ã䜿çšããŠããŒãžãäœæã§ããªãå Žåã¯ã IServiceLocatorå®è£
ãŸãã¯Activator.CreateInstanceã䜿çšããåŸæ¥ã®æ¹æ³ã䜿çšããŠããŒãžãšã³ã³ãããŒã«ãäœæãããããã«ã WebFormViewãæŽæ°ãããŸããã
ã°ããŒãã«ãã£ã«ã¿ãŒ
MVC 3ã¯ãã³ã³ãããŒã©ãŒã®ã¢ã¯ã·ã§ã³ãåŒã³åºããããã³ã«åŒã³åºããããã£ã«ã¿ãŒãå®çŸ©ã§ããã°ããŒãã«ãã£ã«ã¿ãŒã¡ã«ããºã ãè¿œå ããŸãã ãã£ã«ã¿ãŒãè¿œå ããã«ã¯ãã°ããŒãã«éçã¯ã©ã¹
GlobalFiltersã䜿çšãããŸãã
GlobalFilters.Filters.AddïŒæ°ããMyActionFilterïŒïŒïŒ;
æ°ãã
IFilterProviderã€ã³ã¿ãŒãã§ã€ã¹ã®ã€ã³ãžã§ã¯ã·ã§ã³ãäœæããããšã«ãããã°ããŒãã«ãã£ã«ã¿ãŒã¡ã«ããºã ããªãŒããŒã©ã€ãã§ããŸãã ããã«ãããã°ããŒãã«ãã£ã«ã¿ãå®è¡ããããã®ç¬èªã®ããžãã¯ãäœæã§ããŸãã
JsonValueProviderFactoryå€ãããã€ããŒ
æ°ããå€ãããã€ããŒã䜿çšãããšãã¢ã¯ã·ã§ã³ã§JSON圢åŒã®ãã©ã¡ãŒã¿ãŒã»ãããå«ãèŠæ±ãåä¿¡ããã¢ã¯ã·ã§ã³ã¡ãœããã®ãã©ã¡ãŒã¿ãŒã«ãããã§ããŸãã 以åã¯ããã®æ©èœã¯
ASP.NET MVC Futuresã©ã€ãã©ãªã§ãã¹ããããŠ
ããŸããã
ããšãã°ãMIMEã¿ã€ãã
application / jsonã® POSTãªã¯ãšã¹ãã«æ¬¡ã®å€ãå«ãŸããŠããå ŽåïŒ
{ãProductNameãïŒãMilkãããCostãïŒã12.0ã}
次ã«ã
JsonValueProviderFactoryãããã€ããŒã䜿çšããŠ
ããããã®å€ã次ã®ã¢ã¯ã·ã§ã³ã§
ProductModelã¿ã€ãã®ãã©ã¡ãŒã¿ãŒã«èªåçã«å²ãåœãŠãããŸãã
[HttpPost]
Public ActionResult SaveProductïŒProductModel productModelïŒ
{
...
}
ã¿ã€ãProductModelã¯æ¬¡ã®ããã«å®£èšãããŠããŸã
ãããªãã¯ã¯ã©ã¹ProductModel
{
publistring ProductName {get; set;}
ãããªãã¯ã¹ããªã³ã°ã³ã¹ã{get; set;}
}
.NET 4.0æ€èšŒå±æ§ãšIValidatableObjectã®ãµããŒã
ValidationAttributeã¯ã©ã¹ã¯.NET 4.0ã§æŽæ°ããã
ValidationContextåã®ãã©ã¡ãŒã¿ãŒãæã€æ°ãããªãŒããŒ
ããŒããããIsValidã¡ãœããã§æ¡åŒµãããŸããã ãã®ãã©ã¡ãŒã¿ãŒã«ã¯ãæ°ããããããã£å€ã«å ããŠãæ€èšŒã³ã³ããã¹ããšæ€èšŒãªããžã§ã¯ãã®ã€ã³ã¹ã¿ã³ã¹ãå«ãŸããŸãã ããã«ãããçŸåšã®ããããã£ã ãã§ãªãããªããžã§ã¯ãã®ä»ã®ããããã£ããã§ãã¯ãããããã®å€ã«åºã¥ããŠæ€èšŒããããšãã§ããŸãã
äžèšã®äŸã¯ãæ€èšŒã®ã³ã³ããã¹ãã§æž¡ããããªããžã§ã¯ãã®2ã€ã®ããããã£ã®æ¯èŒã瀺ããŠããŸãã
ããã«ãæ°ãã
IValidatableObjectã€ã³ã¿ãŒãã§ã€ã¹ã.NET 4.0ã«è¿œå
ãããŸãããããã«ãããã¢ãã«ã®ã¯ã©ã¹ã¬ãã«ã§æ€èšŒããžãã¯ãå®çŸ©ã§ããŸãã
äžèšã§å®çŸ©ãããã¢ãã«ã¯ãç¬èªã®æ€èšŒã®ããã«
IValidatableObjectã€ã³ã¿ãŒãã§ã€ã¹ãå®è£
ããŸãã MVC 3ã¯ãã®ã€ã³ã¿ãŒãã§ã€ã¹ããµããŒãããããã«åºã¥ããŠã¢ãã«ãæ€èšŒããŸãã
ã€ã³ã¿ãŒãã§ã€ã¹IClientValidatable
ãã®æ°ããã€ã³ã¿ãŒãã§ãŒã¹ã¯
ã¯ã©ã€ã¢ã³ãæ€èšŒã®ãµããŒãã«é¢ããæ
å ±ããµãŒãããŒãã£ã®æ€èšŒãã¬ãŒã ã¯ãŒã¯ã«æäŸããããã«èšèšãããŠããŸãã
.NET 4ã¡ã¿ããŒã¿å±æ§ã®ãµããŒã
MVC 3ã¯ã.NET 4ã§å°å
¥ãããæ°ããã¡ã¿ããŒã¿å±æ§ããµããŒãããŠããŸããããšãã°ãDisplayAttributeã§ãã MVC 3ã§å®éã«äœ¿çšãããŠããæ°ããå±æ§ã®å®å
šãªãªã¹ãã¯ãŸã å©çšã§ããŸããããã®åé¡ã«é¢ããæ
å ±ã¯ãªãããããžã§ã¯ãã®ãœãŒã¹ã³ãŒãã¯ãŸã å©çšã§ããŸããã
IMetadataAware
æ°ããã€ã³ã¿ãŒãã§ãŒã¹ã¯æ¬¡ã®ããã«å®çŸ©ãããŸã
ã¢ãã«ã®ã¡ã¿ããŒã¿ããã€äœæãããããå€æãããã®æç¹ã§è¿œå ã®ã¢ã¯ã·ã§ã³ãå®è¡ã§ããããã«ããããšãç®çãšããŠããŸãã ãã®ã€ã³ã¿ãŒãã§ãŒã¹ã¯ãããšãã°ãDataAnnotationsã¡ã¿ããŒã¿ã¯ã©ã¹DataAnnotationsModelMetadataProviderãªã©ãAssociatedMetadataProviderããç¶æ¿ãããã¯ã©ã¹ã«ãã£ãŠäœ¿çšãããŸãã
æ°ããã¿ã€ãã®ã¢ã¯ã·ã§ã³çµæ
MVC 3ã¯ãã¢ã¯ã·ã§ã³ã®çµæãè¿ãããã®ããã€ãã®æ°ããã¿ã€ããå°å
¥ããŸããã
HttpNotFoundResult
èŠæ±ããããªãœãŒã¹ãèŠã€ãããªãã£ãããšã瀺ãçµæãè¿ãåçŽãªã¢ã¯ã·ã§ã³çµæã¿ã€ãïŒHTTP 404ïŒã ã³ã³ãããŒã©ãŒã«ã¯ã
HttpNotFoundResultåãè¿ãæ°ãããã«ããŒã¡ãœãã
HttpNotFound ïŒïŒãå«ãŸããŠããŸãã
HttpStatusCodeResult
ãšããŠå®£èšãããæ°ããã¯ã©ã¹
HttpStatusCodeResultã¯ã©ã¹
㯠ãã¢ã¯ã·ã§ã³ã®çµæãšããŠä»»æã®HTTPã³ãŒããè¿ãããã«èšèšãããŠããŸãã
ã芧ã®ãšãããããã«ã¯HTTPã³ãŒãã®ããžã¿ã«å€ãåãå
¥ãã2ã€ã®ã³ã³ã¹ãã©ã¯ã¿ãŒãå«ãŸãã2çªç®ã®ã³ã³ã¹ãã©ã¯ã¿ãŒã«ã¯çµæã®èª¬æãå«ãè¿œå ã®è¡ããããŸãã
äžå®ã®ãªãã€ã¬ã¯ã
MVC3ã¯ãã¢ã¯ã·ã§ã³çµæãæ°žç¶çãªãªãã€ã¬ã¯ãïŒHTTP 301ïŒãšããŠè¿ããµããŒããè¿œå ããŸãã ããã¯ã次ã®æ°ããã³ã³ãããŒã©ãŒã¡ãœããã䜿çšããŠå®è¡ã§ããŸãã
- RedirectPermanent-æå®ãããURLã«ãªãã€ã¬ã¯ãããŸãã
- RedirectToRoutePermanent-çŸåšã®ã«ãŒãã«ãªãã€ã¬ã¯ãããŸãïŒãŸãã¯ããªãã·ã§ã³ã®ãã©ã¡ãŒã¿ãŒrouteNameãšrouteValuesãæå®ã§ããŸãïŒã
- RedirectToActionPermanent-æå®ãããã¢ã¯ã·ã§ã³ã«ãªãã€ã¬ã¯ãããŸãïŒãªãã·ã§ã³ã®ãã©ã¡ãŒã¿ãŒcontrollerNameãšrouteValuesãæå®ã§ããŸãïŒã
MVC2ãšäºææ§ã®ãªãå€æŽ
äŸå€ãã£ã«ã¿ãŒã®å®è¡é åºãå€æŽãããŸããã 以åã¯ãã³ã³ãããŒã©ãŒã«é©çšãããäŸå€ãã£ã«ã¿ãŒã¯ãã¢ã¯ã·ã§ã³ã«é©çšããããã£ã«ã¿ãŒãããæ©ãå®è¡ãããŠããŸããïŒãããã®ãã£ã«ã¿ãŒã®Orderå€ãåãå ŽåïŒã çŸåšããã®åäœã¯å€åããŠããŸãã ã¢ã¯ã·ã§ã³ã®äŸå€ãã£ã«ã¿ãŒãæåã«å®è¡ããããã®åŸã³ã³ãããŒã©ãŒã«é©çšããããã£ã«ã¿ãŒãå®è¡ãããŸãã ãããã®ãã£ã«ã¿ãŒã®Orderå€ãç°ãªãå ŽåãOrderã§å®çŸ©ãããé åºã«åŸã£ãŠã以åãšåæ§ã«å®è¡ãããŸãã
æ¢ç¥ã®åé¡
ãã®ãªãªãŒã¹ã«ã¯ãå°æ¥ã®ãªãªãŒã¹ã§å¯ŸåŠãããå€ãã®åé¡ããããŸãã
- Visual Studioã«ã¯ãRazorãã¬ãŒã³ããŒã·ã§ã³ãšã³ãžã³çšã®æ§æã®åŒ·èª¿è¡šç€ºãšIntelliSenseã®ãµããŒãã¯ãããŸããã
- ãã¡ã€ã«ãç·šéãããšãã«ãã³ã³ãããŒã©ãŒã«ç§»åãæ©èœã䜿çšããæ¹æ³ã¯ãããŸããã cshtml ïŒã«ããœãªïŒ;
- Razorãã¥ãŒãšã³ãžã³ã䜿çšããŠã³ãŒããç·šéããå ŽåãVisual Studioã¹ããããã«ã¢ã¯ã»ã¹ã§ããŸããã
ãããã«
æåã®äºåãªãªãŒã¹ã®çµæã«ãããšãASP.NET MVC 3ã®æ°ããããŒãžã§ã³ã¯å€ãã®æ°æ©èœããããããšèªä¿¡ãæã£ãŠèšããŸãã æ©èœã¯ç¶ç¶çãªç 究ã®ããã«ãã§ã«å©çšå¯èœã§ãããå°æ¥ã®ãªãªãŒã¹ã§ã¯æ°ããæ©èœã®æ°ãå¢ããã ãã ãšæããŸãã
ãã®ãããæ°ããæ©èœãç 究ããã³ãã¹ãããããã«ãäºåããŒãžã§ã³ãéšåçã«çºè¡ãããŠããŸãã ãã¹ãŠã®ASP.NET MVCéçºè
ã«ãMVC3 Preview 1ãªãªãŒã¹ã«çŽ°å¿ã®æ³šæãæãããã®æ°æ©èœã®èª¿æ»ã«æéãå²ããããå§ãããŸãã