ASP.NET MVC as the next step in web development
-
Upload
volodymyr-voytyshyn -
Category
Documents
-
view
1.822 -
download
2
Transcript of ASP.NET MVC as the next step in web development
![Page 1: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/1.jpg)
Volodymyr Voytyshyn08/27/2011
ASP.NET MVCas the next stepin web development
![Page 2: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/2.jpg)
Goal
What is ASP.NET MVC?
![Page 3: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/3.jpg)
Contents
About MVC Pattern
ASP.NET Platform
Sample Application
ASP.NET MVC Project Concepts
ASP.NET MVC Key Features
MVC vs WebForms
Conclusion
![Page 4: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/4.jpg)
ABOUT MVC PATTERN
![Page 5: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/5.jpg)
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
![Page 6: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/6.jpg)
Main Idea of MVC
Separate view and data source
View
Model Controller
![Page 7: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/7.jpg)
Classic MVC (Active Model)
Model
ViewHandle view events
Update data
Data Source
Controller
Get
dat
a
Noti
fy fo
r Ch
ange
s
Mediator
![Page 8: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/8.jpg)
Classic MVC (Passive Model)
Model
ViewHandle view events
Update data
Data Source
ControllerGet
dat
a Notify for Changes
Mediator
![Page 9: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/9.jpg)
MVP
ViewHandle view events
Update data
Model
PresenterPut data
MediatorGet data
![Page 10: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/10.jpg)
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
![Page 11: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/11.jpg)
ASP.NET PLATFORM
![Page 12: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/12.jpg)
ASP.NET Web Forms Key Versions
ASP.NET 1.02002
ASP.NET 2.02005
ASP.NET 3.52007
ASP.NET 4.02010
ASP1998
![Page 13: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/13.jpg)
ASP.NET MVC Key Versions
ASP.NET MVC 12009
ASP.NET MVC 22010
ASP.NET MVC 32011
ASP.NET
![Page 14: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/14.jpg)
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
![Page 15: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/15.jpg)
SAMPLE APPLICATION
![Page 16: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/16.jpg)
Concept
Project name: “Easy Reporting”
Idea: time tracking system for developers
![Page 17: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/17.jpg)
Key Use Cases
uc Use Case
Dev eloper Manager
Report working time Confirm dev eloper's working time
Manage tasksManage projects
![Page 18: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/18.jpg)
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»
![Page 19: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/19.jpg)
BASIC CONCEPTS OF MVC PROJECT
![Page 20: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/20.jpg)
Typical MVC Project Structure
![Page 21: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/21.jpg)
Simple Controller and Action
Controller
Action
ProjectController.cs
![Page 22: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/22.jpg)
Simple ViewIndex.cshtml
![Page 23: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/23.jpg)
Simple Client Page
![Page 24: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/24.jpg)
Mediator
MVC Implementation
Controller
ActionView
Model
Client
![Page 25: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/25.jpg)
ASP.NET MVC KEY FEATURES
![Page 26: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/26.jpg)
Action Results
ActionResult – base class of result of an action
View Redirect JavaScript Json
File HTTP Content Empty
![Page 27: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/27.jpg)
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
![Page 28: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/28.jpg)
Action Filters: Example
ProjectController.cs
![Page 29: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/29.jpg)
View Engines Concept
Razor
*.aspx / *.ascx / *.master
Etc.
ASP.NET MVC
![Page 30: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/30.jpg)
Passing data into View
Action View
Model
ViewData
ViewBag
TempData
![Page 31: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/31.jpg)
HTML Helpers
HTML Helper – “server control” in ASP.NET MVC
Classic HTML Helpers Declarative HTML Helpers
![Page 32: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/32.jpg)
Partial Views
Partial view – “user control” in ASP.NET MVC
_Layout.cshtml
Footer.cshtml
Header.cshtml
![Page 33: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/33.jpg)
Layout pages and sections
Layout page – “master page” in ASP.NET MVC
Section – “ContentPlaceHolder” in ASP.NET MVC
![Page 34: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/34.jpg)
Routing
Controller
ActionClient
Params
Routing Engine
URL
Default route - /controller/action/id
![Page 35: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/35.jpg)
Dependency Injection
IServiceLocator MvcServiceLocator
Controller Factory
Controller
View
Action FilterInstantiate
Service Locator Implementation
Setup
Implement
![Page 36: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/36.jpg)
Unit Testing
Can be tested:– Controllers– Routes– Html helpers– UI Models– View logic– Etc.
UsingInversion of Control
principle
TestableApplication
![Page 37: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/37.jpg)
MVC Control Libraries
Client Side Controls
JQuery IU
DOJO
Etc.
Server Side Controls
Telerik
DevExpress
Etc.
![Page 38: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/38.jpg)
MVC VS WEBFORMS
![Page 39: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/39.jpg)
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
![Page 40: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/40.jpg)
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
![Page 41: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/41.jpg)
MVC Disadvantages
Speed of development (particularly in early stages)
… but you can win when you make changes in finished product
![Page 42: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/42.jpg)
Conclusion
Convenient
Easier
Clearer
Faster
ASP.NET MVC
![Page 43: ASP.NET MVC as the next step in web development](https://reader035.fdocuments.in/reader035/viewer/2022081511/554a54fdb4c905522f8b4b4c/html5/thumbnails/43.jpg)
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