Introducing ASP.NET MVC

Post on 31-Dec-2015

34 views 0 download

description

Introducing ASP.NET MVC. 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, Corporate Vice President , Microsoft. Objectives. Why MVC? ASP.NET MVC In Detail Better Integration - PowerPoint PPT Presentation

Transcript of Introducing ASP.NET MVC

Ori Calvo, 2010Ori.calvo@gmail.com

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

Scott Guthrie, Corporate Vice President, Microsoft

ObjectivesWhy MVC?ASP.NET MVC In DetailBetter IntegrationConclusions

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

Quick DemoCreate new MVC ProjectCreate new controllerCreate new View

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

HTML5CSS3

Multidiscipline Web ServerHTML GenerationData ServicesService Orientation

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

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

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

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

Web Platform Installer

MVC IngredientsRouting SystemControllerActionFilterViewModelModel StateView Data

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

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)

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

Controller Base ClassActionAction resultFilters

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

public ViewResult ShowGreeting(){

return View(“MyView”);}

}

Controller – Producing OutputTypes of action results

ViewPartialViewRedirectJsonJavaScriptFileContentOthers

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

Controller - Receiving InputUse context objects

HttpContextRouteDataTempData

Implicit model bindingThrough action parametersEasier to test

Explicit model bindingFull control

Model BindingIs built from

FormRouteDataQueryString

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

DemoAdd Master PageAdd Partial View

DemoAdd Authentication filterImplement custom filterRegister global filter

Action FilterAttach reusable behavior

LoggingAuthorizationCaching

Inject extra logicGreat from testing perspective

Action filter implements IActionFilterResult filter implements IResultFilterActionFilterAttribute implements both

Demo – Entity FrameworkGenerate model from DBImplement BL interfaces

Demo - jQueryUnobtrusive JavaScriptPartial RefreshWorking with JSONClient side templatesjQuery UI

Demo - TestingAdd test projectIoC patternControllerBuilder

Questions ?

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?

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 !!!

Thank You !!!