jean-claude trachsel senior consultant trivadis ag building a website with asp.net mvc
TRANSCRIPT
Jean-Claude TrachselSenior ConsultantTrivadis AG
Building a Website withASP.NET MVC
My ProfileDon’t hesitate to contact me
IT SOLUTIONS, SERVICES, & PRODUCTS
TECHNOLOGIESMicrosoft, Oracle, IBM, Open Source
Integration, Application Performance Management, Security
TrainingManaged Services
InfrastructureEngineering
Application Development
Enterprise Content Management
BUSINESS INTEGRATION SERVICES
ITdepartmen
ts
Businessdepartmen
ts
CUSTOMER
Business Intelligence
Trivadis solutions portfolio and competences
Hamburg
Düsseldorf
Frankfurt
Stuttgart
MunichFreiburg
Vienna
Basel
Bern
Zurich
Lausanne~370 employees
~170 employees
~20 employees
Trivadis facts & figures11 Trivadis locations with more than 550 employees
Financially independent and sustainably profitable
Key figures 2010
Revenue CHF 101 / EUR 73 mio.
Services for more than 700 clients in over 1‘800 projects
Over 170 Service Level Agreements
More than 5'000 training participants
Research and development budget:
CHF 5.0 / EUR 3.6 mio.
Agenda
What is ASP.NET MVCBuilding a WebsiteFeatures we need to know
IntroductionLevel 100
What is ASP.NET MVC
Web Development FrameworkBased on the ASP.NET FrameworkBased on the MVC Design Pattern
Acronym for Model ● View ● ControllerSeparation of concerns
Web Development StackMicrosoft’s HTML Technologies
ASP.NET Web Forms ASP.NET MVC
ASP.NET Framework
.NET Framework
Technologie FocusASP.NET
WebForms
Make Web Development fast and easy
Hide Web Specifica
WinForms similar Programming Model
Statefull, event driven, many rich controls
ASP.NET MVC
Full Control Web Development
Great Testability, Maintainability and Extensibility
Stateless, trendy, separation of concerns,perfect ajax integration
Agenda
What is ASP.NET MVCBuilding a WebsiteFeatures we need to know
ModelControllerViewTest
IntroductionStep one
Build a website in 5 stepsAdventureWorks DBCRUD Functionality for Vendor table
Setup the Solution
Define the Model
Build the ControllerBuild some
Views
Build a Unit Test
DemoStep one
Setup the Solution
Define the Model
Build the ControllerBuild some
Views
Build a Unit Test
Model FundamentalsStep two
ModelBusiness Logic LayerData Access Layer
ArchitectureRepository PatternServices Layer
This is not ASP.NET MVC specific
SolutionModelControll
erViewsUnit Test
Demo ArchitectureMVCProject
Controller
Controller
Controller
ViewViewView
Mod
el
DataProject Entity Framework
ModelDataAnnotations
ServicesProject
IEn…on<T> GetItems();T GetItem(int id);void Save();
IRepository<T> IEnumeration<T>
GetItems();T GetItem(int id);void Save();
VendorRepository
SolutionModelControll
erViewsUnit Test
DemoStep two
Setup the Solution
Define the Model
Build the ControllerBuild some
Views
Build a Unit Test
Controller FundamentalsStep threeController
Class in C# (VB)Handles all interactions and requests
Controller base classProvides many helper methods
Action Return ValuesFor testing purpose
SolutionModelControll
erViewsUnit Test
DemoStep three
Setup the Solution
Define the Model
Build the ControllerBuild some
Views
Build a Unit Test
View FundamentalsStep four
ViewAspx or Razor (.cshtml) FileNo Code Behind File
ControlsNo Server Controls (no ViewState)Pure HTML
CodePresentation Logic in C# (VB) or JavaScriptHtml Helper class
SolutionModelControll
erViewsUnit Test
DemoStep four
Setup the Solution
Define the Model
Build the ControllerBuild some
Views
Build a Unit Test
Unit Test FundamentalsStep fiveTest Controller Logic
Seperate Test ProjectsViewsModels
Usefull toolsDependency Injection (DI)Mock Framework
SolutionModelControll
erViewsUnit Test
DemoStep five
Setup the Solution
Define the Model
Build the ControllerBuild some
Views
Build a Unit Test
Agenda
What is ASP.NET MVCBuilding a WebsiteFeatures we need to know
ValidationFilterRazor
Validation
Supports DataAnnotations FeaturesAttributes on the modelGenerates Client- and Server Code
.NET 4 DA-Features Support (Version 3 Feature)
IsValid overloads in the ValidationAttributeIValidatableObject Interface
Remote Validation Attribute (Version 3 Feature)
Defines Controller and Action for jQuery validation
Filters
Aspect Oriented Programming (AOP) Framework
Integrated in ASP.NET MVCStandard Filters
[HandleError], [Authorize], [OutputCache]Base class for your own filter
Global Filters (Version 3 Feature)Conditional filters thru IFilterProvider
RazorThe new View Engine
Compact, Expressive and FluidEasy to learnIs not a new languageWorks with any Text EditorVisual Studio provides Intellisense and syntax highlighting
Advantages of RazorThe new View Engine
1 character instead of 5 for code blocksRazor: @ (no closing tag needed)Parser has semantic knowledge of C# / VBAspx: <%: %>
Coding is fast, fluid and fun
“Hello world” sample<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master“ Inherits="System.Web.Mvc.ViewPage<Product>" %><asp:Content ID="Title" ContentPlaceHolderID="TitleContent“ runat="server"> Razor Demo</asp:Content><asp:Content ID="Contnt" ContentPlaceHolderID="MainContent" runat="server"> <h2>Razor Demo</h2> Hello World, we got Number 1: <%: Model.Number1 %>
and Number 2: <%: Model.Number2 %>.</asp:Content>@model Trivadis.Models.Product@{View.Title = "Razor Demo";}<h2>Razor Demo</h2>Hello World, we got Number 1: @Model.Number1 and Number 2: @Model.Number2.
Razor
aspx
ResourcesStart today with ASP.NET MVC and Razor
http://www.asp.net/mvchttp://haacked.com/http://stephenwalther.com/blog/http://weblogs.asp.net/scottgu/http://blog.trivadis.com/blogs/
Trivadis TechDays11 Wettbewerb
Gutschein
für einen
kostenlose
n
Trivadis
Training
Tag
1. Preis
2. Preis
3. Preis
Mehr Infos am Trivadis Stand
Mit Signaturvon Thomas Huber
Q&A
© 2011 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.