Introducing ASP.NET MVC

of 32 /32
Ori Calvo, 2010 [email protected]

description

Introducing ASP.NET MVC. Ori Calvo, 2010 [email protected]. “If people want to have maximum reach across * all * devices then HTML will provide the broadest reach” Scott Guthrie, Corporate Vice President , Microsoft. Objectives. Why MVC? ASP.NET MVC In Detail Better Integration - PowerPoint PPT Presentation

Transcript of Introducing ASP.NET MVC

Page 1: Introducing ASP.NET MVC

Ori Calvo, [email protected]

Page 2: Introducing ASP.NET MVC

“If people want to have maximum reach across *all* devices then HTML will provide the broadest reach”

Scott Guthrie, Corporate Vice President, Microsoft

Page 3: Introducing ASP.NET MVC

ObjectivesWhy MVC?ASP.NET MVC In DetailBetter IntegrationConclusions

Page 4: Introducing ASP.NET MVC

PrerequisitesASP.NET DeveloperGood understanding of HTML and HTTPGood understanding of C# 3.0 LanguageNo MVC Experience is required

Page 5: Introducing ASP.NET MVC
Page 6: Introducing ASP.NET MVC

Quick DemoCreate new MVC ProjectCreate new controllerCreate new View

Page 7: Introducing ASP.NET MVC

Web Development TodayBrowsing experience everywhereGreater variety of devices and browsersIncreasing drive for web standards

HTML5CSS3

Multidiscipline Web ServerHTML GenerationData ServicesService Orientation

Page 8: Introducing ASP.NET MVC

Web Development TodayRich Client Side Experience

Did we say HTML5?Easy integration with client side libraries

AgileTest Driven Development

REST over SOAPClean URLs

Ruby on RailsYear 2004MVC basedBuilt-in ORM tool

Page 9: Introducing ASP.NET MVC

Classical ASP.NETHuge shift at that timeObject oriented approachCompiled web pagesStateful UIEvent DrivenDrag and Drop DesignerWindows Forms Developing ExperienceIs here to stay !!!

Page 10: Introducing ASP.NET MVC

What’s wrong with it?Is “Windows Forms” approach suited?Limited control over HTMLEncourages mixing of presentation and logicHard to testViewStateComplex page life cycleHard to integrate with other libraries

Page 11: Introducing ASP.NET MVC

ASP.NET MVCSeparation of concernsBuilt on top of ASP.NET platformTight control over HTMLDesigned to be testableExtensible routing systemBetter integration with 3rd party librariesOpen sourceLanguage innovations

Page 12: Introducing ASP.NET MVC
Page 13: Introducing ASP.NET MVC

Web Platform Installer

Page 14: Introducing ASP.NET MVC

MVC IngredientsRouting SystemControllerActionFilterViewModelModel StateView Data

Page 15: Introducing ASP.NET MVC

DemoIntroduction to PhoneBook BLAdd GroupControllerPass model object to view Add Group.Index ViewConfigure RoutingSupport clickingOutgoing URLUse ViewData

Page 16: Introducing ASP.NET MVC

Routing SystemMakes your URLs clean and human friendlyNo correspondence between files and URLsInbound URLOutgoing URLImplemented by System.Web.Routing.dll

Originally shipped with .NET 3.5 SP1You can use it in your classical ASP.NET 4.0

web pagesWas merged into System.Web.dll (starting 4.0)

Page 17: Introducing ASP.NET MVC

ControllerThe controller is the bossResponsible for application logic

Receiving user inputWork against the domain modelMoving the user between different UI

Implements IControllerSingle method: Execute

Usually derives from Controller

Page 18: Introducing ASP.NET MVC

Controller Base ClassActionAction resultFilters

[OutputCache(Duration=600, VaryByParam”*”)]public class DemoController : Controller{

public ViewResult ShowGreeting(){

return View(“MyView”);}

}

Page 19: Introducing ASP.NET MVC

Controller – Producing OutputTypes of action results

ViewPartialViewRedirectJsonJavaScriptFileContentOthers

Page 20: Introducing ASP.NET MVC

DemoSubmitting data to the controllerUse action filters (GET, POST)Model BindingValidation

Page 21: Introducing ASP.NET MVC

Controller - Receiving InputUse context objects

HttpContextRouteDataTempData

Implicit model bindingThrough action parametersEasier to test

Explicit model bindingFull control

Page 22: Introducing ASP.NET MVC

Model BindingIs built from

FormRouteDataQueryString

The DefaultModelBinderConverts strings into .NET objectsUses .NET “Type Converter” facility

Page 23: Introducing ASP.NET MVC

DemoAdd Master PageAdd Partial View

Page 24: Introducing ASP.NET MVC

DemoAdd Authentication filterImplement custom filterRegister global filter

Page 25: Introducing ASP.NET MVC

Action FilterAttach reusable behavior

LoggingAuthorizationCaching

Inject extra logicGreat from testing perspective

Action filter implements IActionFilterResult filter implements IResultFilterActionFilterAttribute implements both

Page 26: Introducing ASP.NET MVC

Demo – Entity FrameworkGenerate model from DBImplement BL interfaces

Page 27: Introducing ASP.NET MVC

Demo - jQueryUnobtrusive JavaScriptPartial RefreshWorking with JSONClient side templatesjQuery UI

Page 28: Introducing ASP.NET MVC

Demo - TestingAdd test projectIoC patternControllerBuilder

Page 29: Introducing ASP.NET MVC

Questions ?

Page 30: Introducing ASP.NET MVC

ConclusionsA different way to develop web applications

Hopefully, better“Semi” WOW effect

Long term benefitsFeel natural

No rich server control libraryBe ready to integrate other libraries

You must know HTTP and HTML goodWhat about client side MVC?

Page 31: Introducing ASP.NET MVC

Read morehttp://www.hi-tech.co.il/college/

http://www.asp.net/mvchttp://jquery.com/http://jqueryui.com/http://weblogs.asp.net/scottgu/

MVC 3.0 RC is released today !!!

Page 32: Introducing ASP.NET MVC

Thank You !!!