mvc3 development with visual studio 2010
DESCRIPTION
TRANSCRIPT
MVC3 Development with Visual Studio 2010
Harish Ranganathan @ranganh
Senior Developer EvangelistMicrosoft Corporation, India
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
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
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
Upgrading
ASP.NET MVC 3 Application Upgrader
tinyurl.com/upgrademvc3
demoQuick overview of MVC3 and Razor
Multiple View Engine Support
Multiple View Engine Support
protected void Application_Start(){ ViewEngines.Engines.Add(new SparkViewFactory()); …}
Razor
Clean & ConciseBased on Existing LanguagesIntellisenseCode ColorizationUnit Testing Support
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>
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>}
Web Forms to Razor
Open Source Razor Converter
github.com/telerik/razor-converter
demoRazor Views
Global Filters
No longer need attributesApplies to all actions on all controllers
Global Filters
protected void Application_Start(){ GlobalFilters.Filters.Add(new MyActionFilterAttribute()); …}
demoGlobal Action Filters
Dynamic ViewBag
Accessible via propertiesProperties map to ViewData entriesLate-bound
Dynamic ViewBag
<head>
<title>@ViewBag.Title<title></head>
demoDynamic ViewBag
JavaScript and AJAX
JSON BindingjQuery ValidationUnobstrusive JavaScript
Separation of Presentation and ContentNo errors if AJAX isn’t supported
RemoteAttribute
Client Validation
HtmlHelper. ClientValidationEnabled = true;
code
<configuration> <appSettings>
<add key=“ClientValidationEnabled" value="true"/> </appSettings></configuration>
web.config
demoValidations
Resources
ASP.NET MVC 3http://www.asp.net/mvc/mvc3
Scott Gu’s Bloghttp://weblogs.asp.net/scottgu
Phil Haack’s Bloghttp://haacked.com/
Contacts
Bloghttp://geekswithblogs.net/ranganh
Twitter@ranganh
© 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.