Upload
volodymyr-voytyshyn
View
1.822
Download
2
Embed Size (px)
Citation preview
Volodymyr Voytyshyn08/27/2011
ASP.NET MVCas the next stepin web development
Goal
What is ASP.NET MVC?
Contents
About MVC Pattern
ASP.NET Platform
Sample Application
ASP.NET MVC Project Concepts
ASP.NET MVC Key Features
MVC vs WebForms
Conclusion
ABOUT MVC PATTERN
History of MVC Pattern
Concept of MVC is described in 1979 by Trygve Reenskaug (Norway)
One of the first version of MVC is implemented in Smalltallk-80 class library
Main Idea of MVC
Separate view and data source
View
Model Controller
Classic MVC (Active Model)
Model
ViewHandle view events
Update data
Data Source
Controller
Get
dat
a
Noti
fy fo
r Ch
ange
s
Mediator
Classic MVC (Passive Model)
Model
ViewHandle view events
Update data
Data Source
ControllerGet
dat
a Notify for Changes
Mediator
MVP
ViewHandle view events
Update data
Model
PresenterPut data
MediatorGet data
MVP: Key Differences with Classic MVC Presenter knows all about View
Presenter communicates with data source directly
Events in Model and View removed
Presenter implements main presentation logic
Presenter is mediator between Model and View
ASP.NET PLATFORM
ASP.NET Web Forms Key Versions
ASP.NET 1.02002
ASP.NET 2.02005
ASP.NET 3.52007
ASP.NET 4.02010
ASP1998
ASP.NET MVC Key Versions
ASP.NET MVC 12009
ASP.NET MVC 22010
ASP.NET MVC 32011
ASP.NET
ASP.NET Components
ASP.NET Web Forms
ASP.NET MVC
Web Forms View Engine Razor View Engine
ASP.NET CoreCaching
Modules
Pages
Controls
GlobalizationMaster Pages
Handlers
Profile
Membership
Roles
Etc.
Security
SAMPLE APPLICATION
Concept
Project name: “Easy Reporting”
Idea: time tracking system for developers
Key Use Cases
uc Use Case
Dev eloper Manager
Report working time Confirm dev eloper's working time
Manage tasksManage projects
Components cmp Component
Data Access Layer
Presentation Layer
Data Layer
«Web Application»WebUI
«Class Library»DAL
«Class Library»Entities
«database»ER
ASP.NET MVC 3
Repository Pattern
Entity Framework 4
MS SQL Server 2008
ASP.NET Membership
«Class Library»Castle Windsor
Linq to Entities
«use»
«use»
«use»
«use»«use»
BASIC CONCEPTS OF MVC PROJECT
Typical MVC Project Structure
Simple Controller and Action
Controller
Action
ProjectController.cs
Simple ViewIndex.cshtml
Simple Client Page
Mediator
MVC Implementation
Controller
ActionView
Model
Client
ASP.NET MVC KEY FEATURES
Action Results
ActionResult – base class of result of an action
View Redirect JavaScript Json
File HTTP Content Empty
Action Filters
Filter types:– Authorization– Action– Result– Exception
Standard filters:– Authorize– HttpGet– HttpPost– OutputCache– HandleError
Filter scope:– Action– Controller– Application
Action
Action Filter
Action Filter
Action Filters: Example
ProjectController.cs
View Engines Concept
Razor
*.aspx / *.ascx / *.master
Etc.
ASP.NET MVC
Passing data into View
Action View
Model
ViewData
ViewBag
TempData
HTML Helpers
HTML Helper – “server control” in ASP.NET MVC
Classic HTML Helpers Declarative HTML Helpers
Partial Views
Partial view – “user control” in ASP.NET MVC
_Layout.cshtml
Footer.cshtml
Header.cshtml
Layout pages and sections
Layout page – “master page” in ASP.NET MVC
Section – “ContentPlaceHolder” in ASP.NET MVC
Routing
Controller
ActionClient
Params
Routing Engine
URL
Default route - /controller/action/id
Dependency Injection
IServiceLocator MvcServiceLocator
Controller Factory
Controller
View
Action FilterInstantiate
Service Locator Implementation
Setup
Implement
Unit Testing
Can be tested:– Controllers– Routes– Html helpers– UI Models– View logic– Etc.
UsingInversion of Control
principle
TestableApplication
MVC Control Libraries
Client Side Controls
JQuery IU
DOJO
Etc.
Server Side Controls
Telerik
DevExpress
Etc.
MVC VS WEBFORMS
When we do not need MVC?
I need MVC, because
… it is better than Web Forms
… it implements MVC architecture
… I want to escape from view state
… I do not want automatically generated id in HTML
… I want to get full control over HTML
… I want more friendly URLs
MVC Benefits
Automated testing
Powerful AJAX client side
Flexibility, extensibility, clarity
Easy of learning and easy of using
Clearly separated client side and server side
MVC Disadvantages
Speed of development (particularly in early stages)
… but you can win when you make changes in finished product
Conclusion
Convenient
Easier
Clearer
Faster
ASP.NET MVC
Thank You!
Copyright © 2011 SoftServe, Inc.
Contacts
Volodymyr Voytyshyn5 Knyahyni Olhy Str., Rivne 33000, Ukraine
Tel: +38(066) 41 83 509
E-mail: [email protected]@gmail.com
Skype: voytyshin