deep dive into new asp.net mvc 4 features

51
Deep Dive Into MVC 4 Building tomorrows web Peter Himschoo t U2U Trainer MS Regional Director

Upload: microsoft-developer-network-msdn-belgium-and-luxembourg

Post on 15-Nov-2014

3.635 views

Category:

Technology


4 download

DESCRIPTION

An in-depth look ASP.NET MVC 4 features including better integration with NuGet, modern templates to support mobile and responsive websites, display mode, customizing generated code with recipes and more.

TRANSCRIPT

Page 1: Deep dive into new ASP.NET MVC 4 Features

Deep Dive Into MVC 4Building tomorrows web

Peter HimschootU2U Trainer MS Regional Director

Page 2: Deep dive into new ASP.NET MVC 4 Features

About me…

Peter [email protected]

U2UTraining company based in BrusselsSpecialized in developer training For .NET, SharePoint, HTML5

www.u2u.be

Page 3: Deep dive into new ASP.NET MVC 4 Features

Session Contents• Building Tomorrows Web• Responsive Web Design• New MVC4 project templates

• Mobile Web• Mobile MVC4 features

• NuGet Code Generation Recipes

Page 4: Deep dive into new ASP.NET MVC 4 Features

Building Tomorrows Web

Page 5: Deep dive into new ASP.NET MVC 4 Features
Page 6: Deep dive into new ASP.NET MVC 4 Features

Yesterday’s Web

Server

Server does all the work

ASP.NETWeb Forms

Page 7: Deep dive into new ASP.NET MVC 4 Features

Today’s Web

Server

We share the work

JavaScript

ASP.NETMVC

HTML5

Page 8: Deep dive into new ASP.NET MVC 4 Features

+

Page 9: Deep dive into new ASP.NET MVC 4 Features

Tomorrow’s Web

Server

JSON

jQueryKnockOut.js

ASP.NETMVC

HTML5

Page 10: Deep dive into new ASP.NET MVC 4 Features

Responsive Web Design

Page 11: Deep dive into new ASP.NET MVC 4 Features

Web Design• Now has to support many screen sizes• Personal computer• Tablet• Mobile• Landscape and portrait

Page 12: Deep dive into new ASP.NET MVC 4 Features

960px

566px 331px

566 / 960 = 58.958333%

331 / 960 = 34.47916%

Page 13: Deep dive into new ASP.NET MVC 4 Features

360px

90%

90%

@media only screen and (max-width: 360px)

Page 14: Deep dive into new ASP.NET MVC 4 Features

MVC 4 site templates• Updated to support all resolutions• Mobile web template

Page 15: Deep dive into new ASP.NET MVC 4 Features

DemoA look at the new project templates

Page 16: Deep dive into new ASP.NET MVC 4 Features

Async

Page 17: Deep dive into new ASP.NET MVC 4 Features

Async Controller• Long running actions• Especially IO-intensive

• Use new async support• Better server-side performance

Page 18: Deep dive into new ASP.NET MVC 4 Features

Normal controller example

With intense IO

public class UploadController : Controller{ public ActionResult Upload() { ... Request.Files[upload].SaveAs(Path.Combine(path, filename)); return Json(Path.GetFileNameWithoutExtension(filename)); }

Page 19: Deep dive into new ASP.NET MVC 4 Features

Async Controller

Derive from AsyncControllerpublic async Task<ActionResult> Upload_Async(){ var task = Task<ActionResult>.Factory.StartNew(() => { ... Request.Files[upload].SaveAs(Path.Combine(path, filename)); return Json(Path.GetFileNameWithoutExtension(filename)); }); await task; return task.Result;}

Page 20: Deep dive into new ASP.NET MVC 4 Features

DemoMaking a long running action asynchronous

Page 21: Deep dive into new ASP.NET MVC 4 Features

Adding Mobile support

Page 22: Deep dive into new ASP.NET MVC 4 Features

Mobile Web <> Desktop Web• MVC4 supports this• jQuery Mobile• Display Modes

Controller

Normal View

Mobile ViewMobile Views

Page 23: Deep dive into new ASP.NET MVC 4 Features

Using the ViewPort meta-tag<meta name="viewport" content="width=device-width" />

Page 24: Deep dive into new ASP.NET MVC 4 Features

DisplayModes Modes

Two built-in display modes

Page 25: Deep dive into new ASP.NET MVC 4 Features

Adding your own display mode• Differentiate between browsers

DisplayModes.Modes.Insert(0, new DefaultDisplayMode("WP"){ ContextCondition = (context => context.Request.UserAgent.IndexOf ("Windows Phone", StringComparison.OrdinalIgnoreCase) >= 0)});

Page 26: Deep dive into new ASP.NET MVC 4 Features

Building a Custom Display Mode

Derive from DefaultDisplayMode classprotected override string TransformPath(string virtualPath, string suffix) { virtualPath = base.TransformPath(virtualPath, suffix); if (CheckCondition()) { virtualPath = virtualPath.Replace("cshtml", string.Format("{0}.cshtml", suffix)); } return virtualPath; }

Page 27: Deep dive into new ASP.NET MVC 4 Features

DemoUsing Display Modes and jQuery Mobile

Page 28: Deep dive into new ASP.NET MVC 4 Features

Code Generation Recipes

An ASP.NET MVC 4 recipe is a dialog box delivered via NuGet with associated user interface (UI) and code used to automate a specific task.

Page 29: Deep dive into new ASP.NET MVC 4 Features

Creating a recipe using a recipe

Page 30: Deep dive into new ASP.NET MVC 4 Features

Recipe skeleton

Folder or File recipe[Export(typeof(IRecipe))]public class MyRecipe : IFolderRecipe{ public bool Execute(ProjectFolder folder) { ... } public bool IsValidTarget(ProjectFolder folder) { ... } public string Description ... public Icon Icon ... public string Name ...}

Page 31: Deep dive into new ASP.NET MVC 4 Features

Publishing the recipe on NuGet• Register an account on nuget.org

• Run following commands

nuget pack <project>.nuspec

nuget push <recipe>.<version>.nupkg

Page 32: Deep dive into new ASP.NET MVC 4 Features

Using the recipe• Add the recipe first using NuGet• Just like any other

• Run recipe using Add... Menu• Wierd... This will change later

Page 33: Deep dive into new ASP.NET MVC 4 Features

DemoBuilding a Recipe

Page 34: Deep dive into new ASP.NET MVC 4 Features

Session Summary• A whole new web is born, so…• Learn JavaScript, jQuery and HTML5• Use JSON for data transfer• MVC4 is excellent platform• Supports latest HTML5 standards• Mobile support AND display modes

Page 35: Deep dive into new ASP.NET MVC 4 Features

Be what’s next• Find everything here

http://aka.ms/mbl-tech• Visual Studio Developer Preview Downloads

http://aka.ms/mbl-tech/devprev• MSDN HTML5 Developer Center

http://aka.ms/mbl-tech/html5

Page 36: Deep dive into new ASP.NET MVC 4 Features

Q&A

Page 37: Deep dive into new ASP.NET MVC 4 Features

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Page 38: Deep dive into new ASP.NET MVC 4 Features

Preferred Text LayoutSize 40pt for the main topicsSize 20pt for the subtopicsSize 20pt for the subtopics

Size 40pt for the main topicsSize 20pt for the subtopicsSize 20pt for the subtopics

Size 40pt for the main topicsSize 20pt for the subtopicsSize 20pt for the subtopics

Page 39: Deep dive into new ASP.NET MVC 4 Features

Choosing Correct Slide TransitionsLimit the slide transitions to two types per deck.Choose from these preferred settings.Fade with 1 second durationReveal with 1.5 second durationPush with 1.5 second duration, from rightPan with 1.5 second duration, from right

Page 40: Deep dive into new ASP.NET MVC 4 Features

All About Charts

Page 41: Deep dive into new ASP.NET MVC 4 Features

Keep Charts Clean & Modern

StatisticalTrend

Statistical Survey

1.0

1.0

80 went to the market

89 stayed home

68 had roast beef

77 had none

1x

1x

.03x .03x

Page 42: Deep dive into new ASP.NET MVC 4 Features

Lots Of Data? Minimalize & Plan

Brand 2

Brand 1

Brand 3

58%19%

IBM

Ora

cle

13%

140M130M 125M

Cis

co

VM

War

e

Oth

er

Apple

.485x

1x

.03x

1.5x

.03x

Page 43: Deep dive into new ASP.NET MVC 4 Features

Pictures can set a mood orevoke emotion, making fora more memorable presentation.

Full Bleed Photos

Page 44: Deep dive into new ASP.NET MVC 4 Features

Full Bleed Photos

Pictures can set a mood orevoke emotion, making fora more memorable presentation.Sometimes a gradient shapebelow the text can help legibility.

Page 45: Deep dive into new ASP.NET MVC 4 Features

Sample Layouts

Page 46: Deep dive into new ASP.NET MVC 4 Features

Sample Layout 1

Size 40pt for the main topicsSize 20pt for the subtopicsSize 20pt for the subtopics

Size 40pt for the main topicsSize 20pt for the subtopicsSize 20pt for the subtopics

Text/Icon/PicText/Icon/Pic

Text/Icon/PicText/Icon/Pic

Page 47: Deep dive into new ASP.NET MVC 4 Features

Sample Layout 3

Text goes hereSupporting text hereSize 20pt for the subtopics

Text goes hereSupporting text goes hereSupporting text goes here

Text/Icon/Pic

Text/Icon/Pic

Text/Icon/Pic

Text/Icon/Pic

Text/Pic

Page 48: Deep dive into new ASP.NET MVC 4 Features

Sample Layout 4Text goes hereSupporting text hereSize 20pt for the subtopics

Text goes hereSupporting text goes hereSupporting text goes here

Text goes hereSupporting text goes hereSupporting text goes here

Text/Icon/Pic

Text/Icon/Pic

Text/Pic

Page 49: Deep dive into new ASP.NET MVC 4 Features

Sample Layout 8

Text/Icon/PicText/Icon/Pic

Text/Icon/PicText/Icon/Pic

Text/Pic

Page 50: Deep dive into new ASP.NET MVC 4 Features

Simple, clean, &impactful text here.

Page 51: Deep dive into new ASP.NET MVC 4 Features

Simple, clean, &impactful text here.