2013 ArchitectNow. ASP.NET MVC Pre-Compiler | Workbook. Page 2 of 11 .....
demonstrations will be done in Microsoft Visual Studio 2013 using MVC 5. ... Pro
ASP.NET MVC 3 Framework by Adam Freeman and Steven Sanderson. ▫ Source
: ...
ArchitectNow’s ASP.NET MVC Pre-Compiler Class Workbook
PRESENTED BY:
Kevin Grossnicklaus President
Office 800.362.3919 x101 Email
[email protected] Twitter @kvgros More info at www.architectnow.net
ASP.NET MVC Pre-Compiler | Workbook
CONTENTS Overview ............................................................................................................................................................................. 4 Tools and Skills................................................................................................................................................................. 4 Tools ................................................................................................................................................................................ 4 Required Skills ............................................................................................................................................................. 4 Learning Resources ........................................................................................................................................................ 5 General Links ................................................................................................................................................................ 5 Library Links .................................................................................................................................................................. 5 Misc Links ...................................................................................................................................................................... 5 Books ............................................................................................................................................................................... 5 Blogs ................................................................................................................................................................................ 5 Visual Studio Extensions .......................................................................................................................................... 5 Part 1 – Introduction to MVC ..................................................................................................................................... 7 Brief History of MVC .................................................................................................................................................. 7 Creating your First MVC Application................................................................................................................... 7 Controllers and Actions ............................................................................................................................................ 7 Views ............................................................................................................................................................................... 8 Introduction to Razor ................................................................................................................................................ 8 MVC Routing ................................................................................................................................................................ 8 HTML Helpers .............................................................................................................................................................. 9 Layouts ........................................................................................................................................................................... 9 Models ............................................................................................................................................................................ 9 Receiving Input............................................................................................................................................................ 9 Extending our First MVC Application .................................................................................................................. 9 Part 2 – Advanced Topics ............................................................................................................................................. 9 Referencing Content ................................................................................................................................................. 9 Areas ................................................................................................................................................................................ 9 Testing ......................................................................................................................................................................... 10 Partial Views and Sections ................................................................................................................................... 10 Model Templates ..................................................................................................................................................... 10
© 2013 ArchitectNow
ASP.NET MVC Pre-Compiler | Workbook
Page 2 of 11
ASP.NET MVC Pre-Compiler | Workbook
Filters ............................................................................................................................................................................ 10 Extensibility ................................................................................................................................................................ 10 Ajax ............................................................................................................................................................................... 10 Security ........................................................................................................................................................................ 10 Advanced ActionResults ....................................................................................................................................... 11 Mobile Development ............................................................................................................................................. 11 JQuery Libraries ........................................................................................................................................................ 11 Misc Topics ................................................................................................................................................................ 11
© 2013 ArchitectNow
ASP.NET MVC Pre-Compiler | Workbook
Page 3 of 11
ASP.NET MVC Pre-Compiler | Workbook
OVERVIEW The contents of this workbook are intended as an outline and set of resources to be used by attendees of the ArchitectNow – ASP.NET MVC Pre-Compiler. Questions regarding the content of this workbook can be sent to
[email protected].
TOOLS AND SKILLS TOOLS The following tools may be used to work though the exercises in this workshop. All classroom demonstrations will be done in Microsoft Visual Studio 2013 using MVC 5.
Visual Studio 2013 o Unified ASP.NET (Including MVC 5) Visual Studio 2012 o MVC 3 o MVC 4 o MVC 5 (w/ separate download) Visual Studio 2010 o MVC 2 o MVC 3 o MVC 4 (w/ separate download) Microsoft Web Platform Installer Browsers o IE o Chrome o Safari o FireFox
REQUIRED SKILLS
C# or VB.NET – Moderate Expertise Linq and Lambda Expressions Dynamic Types HTML and JavaScript expertise o Understanding of JQuery Knowledge of external JavaScript libraries
© 2013 ArchitectNow
ASP.NET MVC Pre-Compiler | Workbook
Page 4 of 11
ASP.NET MVC Pre-Compiler | Workbook
LEARNING RESOURCES The following resources will greatly increase your knowledge of MVC and web development in general. They are provided as a means to give you “somewhere to turn to” after leaving this session when you get stuck or need additional support. To save you time and effort in entering any of the links below manually, you can download this document at the following location:
GENERAL LINKS
Microsoft Web Development Site: http://www.asp.net/ Microsoft MVC Site: http://www.asp.net/mvc Pluralsight Training Videos: http://www.pluralsight.com
LIBRARY LINKS
JQuery: http://jquery.com/ JQuery Mobile: http://jquerymobile.com/ Knockout.js: http://knockoutjs.com/ SignalR: http://signalr.net/ or http://www.asp.net/signalr Bootstrap CSS: http://twitter.github.com/bootstrap/
MISC LINKS
Theme Forest: http://themeforest.net/
BOOKS
Pro ASP.NET MVC 4 by Adam Freeman Pro ASP.NET MVC 3 Framework by Adam Freeman and Steven Sanderson Source: http://www.apress.com/9781430234043/ Delivering Mobile-Friendly Websites with MVC 4 by Lyle Luppes Architecting Mobile Solutions for the Enterprise by Dino Esposito Pro JQuery by Adam Freeman Javascript and JQuery: The Missing Manual by David Sawyer McFarland
BLOGS
Shawn Wildermuth: http://wildermuth.com/2012/1/18/Modern_Web_Development_-_Part_1
VISUAL STUDIO EXTENSIONS The following Visual Studio extensions are helpful in the development of MVC applications (or any .NET application) although not required for any of the work in this workshop. All are free and quick to download.
NuGet Package Manager
© 2013 ArchitectNow
ASP.NET MVC Pre-Compiler | Workbook
Page 5 of 11
ASP.NET MVC Pre-Compiler | Workbook
Web Tooling Extensions VS Commands for Visual Studio Power Commands for Visual Studio
© 2013 ArchitectNow
ASP.NET MVC Pre-Compiler | Workbook
Page 6 of 11
ASP.NET MVC Pre-Compiler | Workbook
PART 1 – INTRODUCTION TO MVC BRIEF HISTORY OF MVC
ASP.NET Drawbacks MVC Timeline o Original CTP of V1 in 2007 Open Source o MVC, Razor, and Web API are Open Source under the Apache License o Source on CodePlex: http://aspnetwebstack.codeplex.com/ Competition o ASP.NET o Ruby on Rails o PHP Side by Side Option o Migration Plan
CREATING YOUR FIRST MVC APPLICATION
Demo 1
CONTROLLERS AND ACTIONS
Walkthrough of Controllers and Actions Action Naming Conventions Base Controller Helper Methods Navigating to Controllers and Actions o Default Routing Overview Unit Testing Actions ActionResults ActionResult ViewResult PartialViewResult RedirectResult RedirectToRouteResult
© 2013 ArchitectNow
Helper Method
Description
View
Renders a view as a Web page.
PartialView
Renders a partial view, which defines a section of a view that can be rendered inside another view.
Redirect
Redirects to another action method by using its URL.
RedirectToAction RedirectToRoute
Redirects to another action method.
ASP.NET MVC Pre-Compiler | Workbook
Page 7 of 11
ASP.NET MVC Pre-Compiler | Workbook Table Continued
ActionResult ContentResult JsonResult JavaScriptResult FileResult EmptyResult
Helper Method
Description
Content
Returns a user-defined content type.
Json
Returns a serialized JSON object.
JavaScript
Returns a script that can be executed on the client.
File
Returns binary output to write to the response.
(None)
Represents a return value that is used if the action method must return a null result (void).
VIEWS
View Engine Options o Razor o ASP.NET View Selection and Naming Shared Views Sending Data to View o ViewBag o ViewData o Model Sections Partial Views Separation of Logic vs. Display
INTRODUCTION TO RAZOR
Razor Syntax Overview Razor Intro Blog from Guthrie: http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx Strongly Typed Views
MVC ROUTING
Routing Overview Common Routing Scenarios Mapping to Files
© 2013 ArchitectNow
ASP.NET MVC Pre-Compiler | Workbook
Page 8 of 11
ASP.NET MVC Pre-Compiler | Workbook
HTML HELPERS
Walkthrough Common Helpers Writing your own Helpers
LAYOUTS
_ViewStart Setting Layout
MODELS
Passing Data from Controllers to Views ViewModels Data Access Strategies
RECEIVING INPUT
Value Providers Model Binding Generating Editors Default Model Binders Validation
EXTENDING OUR FIRST MVC APPLICATION
PART 2 – ADVANCED TOPICS REFERENCING CONTENT
CSS/Scripts/Images
AREAS
Segmenting MVC Apps into Logical Areas Areas and Routing
© 2013 ArchitectNow
ASP.NET MVC Pre-Compiler | Workbook
Page 9 of 11
ASP.NET MVC Pre-Compiler | Workbook
TESTING
Unit Testing Strategies Sample MVC Unit Tests
PARTIAL VIEWS AND SECTIONS
Efficient User of PartialViews Using Layout Sections
MODEL TEMPLATES
Model Binding Validation Model Templates Customizing Editors
FILTERS
Overview of Filters Common Filters
EXTENSIBILITY
IoC Containers Custom factories for Controllers/Views Other Extensibility Thoughts
AJAX
Making Ajax Calls in MVC Exposing Data via JSON
SECURITY
Membership Providers and MVC
© 2013 ArchitectNow
ASP.NET MVC Pre-Compiler | Workbook
Page 10 of 11
ASP.NET MVC Pre-Compiler | Workbook
ADVANCED ACTIONRESULTS
Returning Files
MOBILE DEVELOPMENT
MVC Mobile Infrastructure JQuery.Mobile Sencha Other?
JQUERY LIBRARIES
JQuery Knockout.js SignalR
MISC TOPICS
Single Page Apps (SPAs) Bundling WebAPI
© 2013 ArchitectNow
ASP.NET MVC Pre-Compiler | Workbook
Page 11 of 11