1 / 11

ASP.NET MVC 2.0

ASP.NET MVC 2.0. 2009-12-23. Intro. http://localhost/Main/Index. class MainContoller { function Index() {. REQUEST. CONTROLLER. RESPONSE. HTML CSS JavaScript. raw data. VIEW. MODEL. Sample. MainController.cs. public class MainController : Controller {

sana
Download Presentation

ASP.NET MVC 2.0

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ASP.NET MVC 2.0 2009-12-23

  2. Intro http://localhost/Main/Index class MainContoller { function Index() { ... REQUEST CONTROLLER RESPONSE HTML CSS JavaScript raw data VIEW MODEL

  3. Sample MainController.cs public class MainController : Controller { public ActionResult Index(int id) { var model = new MainModel(id); return View(“Index”, model); } } Index.aspx MainModel.cs <html> <body> <h1><%= Model.Title %></h1> <p><%= Model.Content %></p> </body> </html> public class MainModel { public int Id; public string Title; public string Content; }

  4. ASPX vs PHP MainController.php MainController.cs class MainController implements Controller { public function Index($id) { $model = new MainModel($id); return $this->View(“Index”, model); } } public class MainController : Controller { public ActionResult Index(int id) { var model = new MainModel(id); return View(“Index”, model); } } Index.aspx Index.php <html> <body> <h1><%= Model.Title %></h1> <p><%= Model.Content %></p> <img src=“<%= Html.FindFile(“image.jpg”) %>” /> <div><%= ViewData[“Foo”] %></div> </body> </html> <html> <body> <h1><?= $Model->Title ?></h1> <p><?= $Model->Content ?></p> <img src=“<?= $Html->FindFile(“image.jpg”) ?>” /> <div><?= $ViewData[“Foo”] ?></div> </body> </html>

  5. ASP.NET MVC 1.0 • community (ms-pl) • MVC frame • url rewriting and routing • basic validation • helpers (html generators) • page caching

  6. ASP.NET MVC 2.0 • templated helpers • areas • support for Data Annotations • client validation • AsyncController • strongly-typed input helpers • bug fixes, minor features

  7. Sample 1 public class ProductViewModel { [Price(MinPrice = 1.99)] public double Price { get; set; } [Required] public string Title { get; set; } }

  8. Sample 2 [ChildActionOnly] public ActionResult Menu() { var menu = ... return PartialView(menu); } Partial rendering <%= Html.Action("Menu") %> - builds a string and then sends to output <%= Html.RenderAction("Menu") %> - direct outtput

  9. Community developers • extra helpers • T4 templates • localization • programming techniques • blogs, tutorials • partial caching (donut caching) • webshop (cart, order, PayPal) • Oxite

  10. Road map • MVC (pattern) – 1979 • ASP.NET MVC 1.0 – 17th mar 2009 • ASP.NET MVC 2.0 RC – 17th dec 2009 • ASP.NET MVC 2.0 – ?, integrated in VS2010

  11. Links • http://haacked.com • http://www.asp.net/mvc/gallery • http://aspnet.codeplex.com • Wikipedia: MVC

More Related