ori calvo, 2010 hi-tech college [email protected]

35
Ori Calvo, 2010 Hi-Tech College [email protected]

Upload: olivia-flowers

Post on 11-Jan-2016

220 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

Ori Calvo, 2010Hi-Tech College

[email protected]

Page 2: Ori Calvo, 2010 Hi-Tech College 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

Page 3: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

ObjectivesASP.NET MVC BasicsWhat’s new in ASP.NET MVC 3Summary

Page 4: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

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

Page 5: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com
Page 6: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

Quick DemoCreate new ASP.NET MVC ProjectCreate new controllerCreate new View

Page 7: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

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

Page 8: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

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 9: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

ASP.NET MVCSeparation of concernsTight control over HTMLDesigned to be testableExtensible routing systemBetter integration with 3rd party librariesOpen sourceBuilt on top of ASP.NET platformLanguage innovations

Page 10: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

Software Requirements.NET Framework 4.0Visual Studio 2010Visual Web Developer 2010Can be installed into the bin directory

In case the Web Host does not support it directly

Installation can be automated by Web Platform Installer

Additional components can be installed using NuGet

Page 11: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

Web Platform Installer

Page 12: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

MVC IngredientsRouting SystemControllerActionFilterViewModelModel StateView Bag

Page 13: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

Demo – Real life controllerGroupControllerIndex ViewClick a groupBack to parent

Page 14: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

Demo – Extending ViewsPartial View - MenuLayouts - Header and footerSections – Add “scripts” section

Page 15: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

Demo – Submitting DataCreate new groupMethod selectorAutomatic model bindingValidationDataAnnotationsEdit a groupTryUpdateModeljQuery to set focus

Page 16: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

Demo – Controlling AccessAuthorize filterFormsAuthenticationLoginDetails as ViewModel

Page 17: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

Demo – Routing SystemSimplifying URLsImplement “CMS like” URLs

Page 18: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com
Page 19: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

What’s new?ASP.NET MVC 3NuGet 1.1IIS Express 7.5SQL Server Compact Edition 4.0Web Deploy and Web Farm Framework 2.0Orchard 1.0Web Matrix 1.0Entity Framework Code First (CTP5)

Page 20: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

RazorJust another View EngineBetter integration of C# and HTMLIs focused around the @ characterNo need to set the end of codeIs testableIs extendibleFollows the same compilation model as ASPXCan be compiled at design time

Page 21: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

Razor syntaxUse @ to move between code and HTMLUse @() to specify long expressionUse @{} to run arbitrary code which doesn’t

writes into the response streamUse @: inside code region to move back to

HTMLCan also use <text>

Use @* and *@ for commentsUse @functions to add some functionsUse @inherits to specify different base class

Page 22: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

Demo - RazorResolve ambiguitiesCreate a unit testWrite inline template

Page 23: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

NuGetConsider following scenario

You want to install a library named XX has a dependency on Y You also want to install library named ZZ has a dependency on Y

Need to think about:Where can you get latest of all libraries?What are the dependencies of each library?Is it ok to use the latest release for Y?If not, what happens if Z depends on a different

version of Y than X?

Page 24: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

NuGetA library package managerDeals with packages rather than assembliesAn extension to Visual Studio 2010Not just for ASP.NET MVC projectsPackages come from a well known repositoryAutomatically handling of version conflicts and

updatesOnce package is imported NuGet stays out of

the wayNo integration with TFS

Page 25: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

NuGet AlgorithmNever installs assemblies at machine levelUses bin deployPrefers unification over “side by side”Always picks the lowest version of a

dependency that fits in the range Always move up to the highest build/revisionCan use the Add-BindingRedirect power shell

command

Page 26: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

Demo - NuGetInstall T4MVCInstall NHibernateHandle conflictsGet a list of updates availableCreate a local repositoryGive a look at http://nuget.org

Page 27: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

IIS ExpressQuick installation (less than 10MB)Better support for IIS feature set

SSLIntegrated ModeURL Re-WritingSame configuration schema

Does not require administrator privilegesDoesn’t run as a serviceCan co-exist with full IIS7.x and CassiniWorks on Windows XP SP3 and laterSupports multiple users on the same machineSupports WCF but only over HTTPIntegrated into Visual Studio 2010 SP1 beta

Page 28: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

Demo - IIS ExpressChanging VS to work with IIS ExpressChange VS defaultExecute under Integrated ModeChange application pool using AppCmd.exe

Page 29: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

Demo – EF Code FirstUse DbContextChange the database nameUse SQL CEDispose the contextUse validation

Page 30: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

What’s new in ASP.NET MVC 3?Unobtrusive JavaScriptPosting JSON objectsClass level model validationPartial page output cachingBetter Dependency InjectionViewBagGlobal FiltersSessionless Controller

Page 31: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

ASP.NET MVC vs. ASP.NET Web FormsBoth based on ASP.NET infrastructureSame objectives, different waysBoth server centricHow sophisticated the UI need to be?Are you planning for automation coverage?What is your team developing background?Can mix both in the same projectYou can use ASP.NET Server Controls inside

views (don’t tell anybody …)

Page 32: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

SummaryA different way to develop web applicationsRazor Syntax – Clear & easier to maintainNuGet – Integrate 3rd party librariesIIS Express – IIS for the developerBetter Validation – Based on jQuery and

Unobtrusive JavaScript principlesMany small enhancements

Page 33: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

Questions ?

TryUpdateModel

Page 34: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

Read moreCourse 4282 at Hi-Tech College (Next

Week!!!)

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

Page 35: Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

Thank You !!!