Download presentation
Presentation is loading. Please wait.
Published byAmberlynn Fitzgerald Modified over 9 years ago
1
Asp.Net MVC Adnan Masood Jeff Bergman Sean Xiao
2
Why MVC? Very Clean separation of Concerns Very Clean separation of Concerns Unit Testing Unit Testing Model that leads you down a maintainable path (prevent crappy code) Model that leads you down a maintainable path (prevent crappy code) Clean Urls and Html Clean Urls and Html
3
Front Controller Classic asp.net framework is Page Controller Classic asp.net framework is Page Controller Map Urls to classes/controllers instead of Pages Map Urls to classes/controllers instead of Pages
4
Unit Testing Mock Objects to simulate responses. Mock Objects to simulate responses. Don’t have to go through a page or view Don’t have to go through a page or view Red/Green Testing Red/Green Testing
5
Features Routing Routing Controller Controller View View Dependency Injection Dependency Injection Pluggable Pluggable Interfaces for all core contracts Interfaces for all core contracts
6
Urls Url no longer points to the view/aspx page Url no longer points to the view/aspx page A Url maps to a controller class A Url maps to a controller class Allows more flexibility to map Urls Allows more flexibility to map Urls Url routing engine, Route table Url routing engine, Route table Routes are tokenized strings Routes are tokenized strings Can use RegEx Can use RegEx
7
Route Examples / / / / http://domain/Home/CustomerDetail/45 http://domain/Home/CustomerDetail/45 http://domain/Home/CustomerDetail/45 http://domain/Home/CustomerDetail/45 Html.Link for creating outbound urls Html.Link for creating outbound urls Html.Link(,, ) Html.Link(,, )
8
Controller IController IController Execute(IHttpContext ctx, RouteData routeDate) Execute(IHttpContext ctx, RouteData routeDate) class MyController : Controller class MyController : Controller [ControllerAction] attribute [ControllerAction] attribute
9
Unit Testing Create instance of controller Create instance of controller controller.ViewEngine = new TestViewEngine(); controller.ViewEngine = new TestViewEngine(); Uses Mock Objects Uses Mock Objects
10
View Similar to existing page Similar to existing page No postback or view state No postback or view state Not all page events will fire Not all page events will fire Editing forms will be more work Editing forms will be more work Separate page for viewing, editing, and updating Separate page for viewing, editing, and updating Ajax will use UserControls as update panels but request still goes through the control Ajax will use UserControls as update panels but request still goes through the control
11
View View probably shouldn’t directly access data sources or services. View probably shouldn’t directly access data sources or services. Use the ViewData which stores the model the view is rendering Use the ViewData which stores the model the view is rendering ViewPage, ViewPage ViewPage, ViewPage
12
Future of Asp.Net MVC for the Enterprise MVC for the Enterprise Classic Asp.Net for quicker implementations Classic Asp.Net for quicker implementations
13
Thanks For Coming! PRIZES!!!! PRIZES!!!! Don’t forget we draw prizes on Sunday afternoon, including great products like Acronis and CodeSmith Tools, plus many new books! Don’t forget we draw prizes on Sunday afternoon, including great products like Acronis and CodeSmith Tools, plus many new books! THANKS AGAIN TO OUR CONTRIBUTORS!!!! THANKS AGAIN TO OUR CONTRIBUTORS!!!! Cal State Fullerton (http://www.fullerton.edu) Cal State Fullerton (http://www.fullerton.edu)http://www.fullerton.edu Spherion (www.spherion.com) Spherion (www.spherion.com)www.spherion.com Microsoft (www.microsoft.com) Microsoft (www.microsoft.com)www.microsoft.com Neudesic (www.neudesic.com) Neudesic (www.neudesic.com)www.neudesic.com PDSA Inc. (www.pdsa.com) PDSA Inc. (www.pdsa.com)www.pdsa.com QuickStart (www.quickstart.com) QuickStart (www.quickstart.com)www.quickstart.com Harbor Objects (www.harborobjects.com) Harbor Objects (www.harborobjects.com)www.harborobjects.com Odyssey Consulting Group (www.ocgpros.com) Odyssey Consulting Group (www.ocgpros.com)www.ocgpros.com IDesign Inc. (www.idesign.net) IDesign Inc. (www.idesign.net)www.idesign.net
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.