32
Ori Calvo, 2010 [email protected]

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

Embed Size (px)

Citation preview

Page 1: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

Ori Calvo, [email protected]

Page 2: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

“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: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

ObjectivesWhy MVC?ASP.NET MVC In DetailBetter IntegrationConclusions

Page 4: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

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

Page 5: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,
Page 6: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

Quick DemoCreate new MVC ProjectCreate new controllerCreate new View

Page 7: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

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

HTML5CSS3

Multidiscipline Web ServerHTML GenerationData ServicesService Orientation

Page 8: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

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: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

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

Page 10: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

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: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

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: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,
Page 13: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

Web Platform Installer

Page 14: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

MVC IngredientsRouting SystemControllerActionFilterViewModelModel StateView Data

Page 15: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

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

Page 16: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

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: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

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: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

Controller Base ClassActionAction resultFilters

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

public ViewResult ShowGreeting(){

return View(“MyView”);}

}

Page 19: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

Controller – Producing OutputTypes of action results

ViewPartialViewRedirectJsonJavaScriptFileContentOthers

Page 20: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

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

Page 21: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

Controller - Receiving InputUse context objects

HttpContextRouteDataTempData

Implicit model bindingThrough action parametersEasier to test

Explicit model bindingFull control

Page 22: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

Model BindingIs built from

FormRouteDataQueryString

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

Page 23: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

DemoAdd Master PageAdd Partial View

Page 24: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

DemoAdd Authentication filterImplement custom filterRegister global filter

Page 25: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

Action FilterAttach reusable behavior

LoggingAuthorizationCaching

Inject extra logicGreat from testing perspective

Action filter implements IActionFilterResult filter implements IResultFilterActionFilterAttribute implements both

Page 26: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

Demo – Entity FrameworkGenerate model from DBImplement BL interfaces

Page 27: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

Demo - jQueryUnobtrusive JavaScriptPartial RefreshWorking with JSONClient side templatesjQuery UI

Page 28: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

Demo - TestingAdd test projectIoC patternControllerBuilder

Page 29: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

Questions ?

Page 30: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

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: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

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: Ori Calvo, 2010 Ori.calvo@gmail.com. “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,

Thank You !!!