25
MVC3 Development with Visual Studio 2010 Harish Ranganathan @ranganh Senior Developer Evangelist Microsoft Corporation, India

MVC3 Development with visual studio 2010

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: MVC3 Development with visual studio 2010

MVC3 Development with Visual Studio 2010

Harish Ranganathan @ranganh

Senior Developer EvangelistMicrosoft Corporation, India

Page 2: MVC3 Development with visual studio 2010

A quick round trip

MVC v 1.0 released in 2009

MVC 2 released in 2010

MVC 3 Tools update in April 2011

MVC 3 released in Jan 2011

Page 3: MVC3 Development with visual studio 2010

What’s new in ASP.NET MVC 3

Razor View EngineMultiple View Engine

SupportValidation

ImprovementsDynamic ViewBag

Global Filters New ActionResultsProject Dialog Improvements

VBHTML Support

Task-based HelpersImproved

Dependency Injection

Porting MVC Script Libraries to jQuery

Granular ValidateInput

Add View Dialog Improvements

Project Dialog Extensibility

Improvements

Improved Caching Support

JSON Binding Support

Page 4: MVC3 Development with visual studio 2010

What’s new in ASP.NET MVC 3

Razor View EngineMultiple View Engine

SupportValidation

ImprovementsDynamic ViewBag

Global Filters New ActionResultsProject Dialog Improvements

VBHTML Support

Task-based HelpersImproved

Dependency Injection

Porting MVC Script Libraries to jQuery

Granular ValidateInput

Add View Dialog Improvements

Project Dialog Extensibility

Improvements

Improved Caching Support

JSON Binding Support

Page 5: MVC3 Development with visual studio 2010

Upgrading

ASP.NET MVC 3 Application Upgrader

tinyurl.com/upgrademvc3

Page 6: MVC3 Development with visual studio 2010

demoQuick overview of MVC3 and Razor

Page 7: MVC3 Development with visual studio 2010

Multiple View Engine Support

Page 8: MVC3 Development with visual studio 2010

Multiple View Engine Support

protected void Application_Start(){ ViewEngines.Engines.Add(new SparkViewFactory()); …}

Page 9: MVC3 Development with visual studio 2010

Razor

Clean & ConciseBased on Existing LanguagesIntellisenseCode ColorizationUnit Testing Support

Page 10: MVC3 Development with visual studio 2010

Syntax Comparison

Web Forms6 transitions

Razor2 transitions

<ul>@for (int i = 0; i < 10; i++){ <li>@i</li>}</ul>

<ul><% for (int i = 0; i < 10; i++) {%> <li><%=i %></li><%} %></ul>

Page 11: MVC3 Development with visual studio 2010

LayoutsLayout View

<html><head>

<title>Title<title></head><body>

@RenderSection("Menu")@RenderBody()

</body></html>

@{Layout="~/Views/Shared/

_Layout.cshtml";}@section Menu {

<ul id="pageMenu"><li>Item 1</li><li>Item 2</li>

</ul>}

Page 12: MVC3 Development with visual studio 2010

Web Forms to Razor

Open Source Razor Converter

github.com/telerik/razor-converter

Page 13: MVC3 Development with visual studio 2010

demoRazor Views

Page 14: MVC3 Development with visual studio 2010

Global Filters

No longer need attributesApplies to all actions on all controllers

Page 15: MVC3 Development with visual studio 2010

Global Filters

protected void Application_Start(){ GlobalFilters.Filters.Add(new MyActionFilterAttribute()); …}

Page 16: MVC3 Development with visual studio 2010

demoGlobal Action Filters

Page 17: MVC3 Development with visual studio 2010

Dynamic ViewBag

Accessible via propertiesProperties map to ViewData entriesLate-bound

Page 18: MVC3 Development with visual studio 2010

Dynamic ViewBag

<head>

<title>@ViewBag.Title<title></head>

Page 19: MVC3 Development with visual studio 2010

demoDynamic ViewBag

Page 20: MVC3 Development with visual studio 2010

JavaScript and AJAX

JSON BindingjQuery ValidationUnobstrusive JavaScript

Separation of Presentation and ContentNo errors if AJAX isn’t supported

RemoteAttribute

Page 21: MVC3 Development with visual studio 2010

Client Validation

HtmlHelper. ClientValidationEnabled = true;

code

<configuration> <appSettings>

<add key=“ClientValidationEnabled" value="true"/> </appSettings></configuration>

web.config

Page 22: MVC3 Development with visual studio 2010

demoValidations

Page 23: MVC3 Development with visual studio 2010

Resources

ASP.NET MVC 3http://www.asp.net/mvc/mvc3

Scott Gu’s Bloghttp://weblogs.asp.net/scottgu

Phil Haack’s Bloghttp://haacked.com/

Page 24: MVC3 Development with visual studio 2010

Contacts

Bloghttp://geekswithblogs.net/ranganh

Twitter@ranganh

Page 25: MVC3 Development with visual studio 2010

© 2010 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.