Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ori Calvo, 2010 “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

Similar presentations


Presentation on theme: "Ori Calvo, 2010 “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,"— Presentation transcript:

1 Ori Calvo, 2010 Ori.calvo@gmail.com

2 “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie, Corporate Vice President, MicrosoftCorporate Vice President

3 Objectives Why MVC? ASP.NET MVC In Detail Better Integration Conclusions

4 Prerequisites ASP.NET Developer Good understanding of HTML and HTTP Good understanding of C# 3.0 Language No MVC Experience is required

5

6 Quick Demo Create new MVC Project Create new controller Create new View

7 Web Development Today Browsing experience everywhere Greater variety of devices and browsers Increasing drive for web standards HTML5 CSS3 Multidiscipline Web Server HTML Generation Data Services Service Orientation

8 Web Development Today Rich Client Side Experience Did we say HTML5? Easy integration with client side libraries Agile Test Driven Development REST over SOAP Clean URLs Ruby on Rails Year 2004 MVC based Built-in ORM tool

9 Classical ASP.NET Huge shift at that time Object oriented approach Compiled web pages Stateful UI Event Driven Drag and Drop Designer Windows Forms Developing Experience Is here to stay !!!

10 What’s wrong with it? Is “Windows Forms” approach suited? Limited control over HTML Encourages mixing of presentation and logic Hard to test ViewState Complex page life cycle Hard to integrate with other libraries

11 ASP.NET MVC Separation of concerns Built on top of ASP.NET platform Tight control over HTML Designed to be testable Extensible routing system Better integration with 3 rd party libraries Open source Language innovations

12

13 Web Platform Installer

14 MVC Ingredients Routing System Controller Action Filter View Model Model State View Data

15 Demo Introduction to PhoneBook BL Add GroupController Pass model object to view Add Group.Index View Configure Routing Support clicking Outgoing URL Use ViewData

16 Routing System Makes your URLs clean and human friendly No correspondence between files and URLs Inbound URL Outgoing URL Implemented by System.Web.Routing.dll Originally shipped with.NET 3.5 SP1 You can use it in your classical ASP.NET 4.0 web pages Was merged into System.Web.dll (starting 4.0)

17 Controller The controller is the boss Responsible for application logic Receiving user input Work against the domain model Moving the user between different UI Implements IController Single method: Execute Usually derives from Controller

18 Controller Base Class Action Action result Filters [OutputCache(Duration=600, VaryByParam”*”)] public class DemoController : Controller { public ViewResult ShowGreeting() { return View(“MyView”);}

19 Controller – Producing Output Types of action results View PartialView Redirect Json JavaScript File Content Others

20 Demo Submitting data to the controller Use action filters (GET, POST) Model Binding Validation

21 Controller - Receiving Input Use context objects HttpContext RouteData TempData Implicit model binding Through action parameters Easier to test Explicit model binding Full control

22 Model Binding Is built from Form RouteData QueryString The DefaultModelBinder Converts strings into.NET objects Uses.NET “Type Converter” facility

23 Demo Add Master Page Add Partial View

24 Demo Add Authentication filter Implement custom filter Register global filter

25 Action Filter Attach reusable behavior Logging Authorization Caching Inject extra logic Great from testing perspective Action filter implements IActionFilter Result filter implements IResultFilter ActionFilterAttribute implements both

26 Demo – Entity Framework Generate model from DB Implement BL interfaces

27 Demo - jQuery Unobtrusive JavaScript Partial Refresh Working with JSON Client side templates jQuery UI

28 Demo - Testing Add test project IoC pattern ControllerBuilder

29 Questions ?

30 Conclusions A different way to develop web applications Hopefully, better “Semi” WOW effect Long term benefits Feel natural No rich server control library Be ready to integrate other libraries You must know HTTP and HTML good What about client side MVC?

31 Read more http://www.hi-tech.co.il/college/ http://www.asp.net/mvc http://jquery.com/ http://jqueryui.com/ http://weblogs.asp.net/scottgu/ MVC 3.0 RC is released today !!!

32 Thank You !!!


Download ppt "Ori Calvo, 2010 “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,"

Similar presentations


Ads by Google