asp.net mvc as the next step in web development

43
Volodymyr Voytyshyn 08/27/2011 ASP.NET MVC as the next step in web development

Upload: volodymyr-voytyshyn

Post on 07-May-2015

1.822 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: ASP.NET MVC as the next step in web development

Volodymyr Voytyshyn08/27/2011

ASP.NET MVCas the next stepin web development

Page 2: ASP.NET MVC as the next step in web development

Goal

What is ASP.NET MVC?

Page 3: ASP.NET MVC as the next step in web development

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

ABOUT MVC PATTERN

Page 5: ASP.NET MVC as the next step in web development

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

Main Idea of MVC

Separate view and data source

View

Model Controller

Page 7: ASP.NET MVC as the next step in web development

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

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

MVP

ViewHandle view events

Update data

Model

PresenterPut data

MediatorGet data

Page 10: ASP.NET MVC as the next step in web development

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

ASP.NET PLATFORM

Page 12: ASP.NET MVC as the next step in web development

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

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

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

SAMPLE APPLICATION

Page 16: ASP.NET MVC as the next step in web development

Concept

Project name: “Easy Reporting”

Idea: time tracking system for developers

Page 17: ASP.NET MVC as the next step in web development

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

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

BASIC CONCEPTS OF MVC PROJECT

Page 20: ASP.NET MVC as the next step in web development

Typical MVC Project Structure

Page 21: ASP.NET MVC as the next step in web development

Simple Controller and Action

Controller

Action

ProjectController.cs

Page 22: ASP.NET MVC as the next step in web development

Simple ViewIndex.cshtml

Page 23: ASP.NET MVC as the next step in web development

Simple Client Page

Page 24: ASP.NET MVC as the next step in web development

Mediator

MVC Implementation

Controller

ActionView

Model

Client

Page 25: ASP.NET MVC as the next step in web development

ASP.NET MVC KEY FEATURES

Page 26: ASP.NET MVC as the next step in web development

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

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

Action Filters: Example

ProjectController.cs

Page 29: ASP.NET MVC as the next step in web development

View Engines Concept

Razor

*.aspx / *.ascx / *.master

Etc.

ASP.NET MVC

Page 30: ASP.NET MVC as the next step in web development

Passing data into View

Action View

Model

ViewData

ViewBag

TempData

Page 31: ASP.NET MVC as the next step in web development

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

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

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

Routing

Controller

ActionClient

Params

Routing Engine

URL

Default route - /controller/action/id

Page 35: ASP.NET MVC as the next step in web development

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

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

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

MVC VS WEBFORMS

Page 39: ASP.NET MVC as the next step in web development

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

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

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

Conclusion

Convenient

Easier

Clearer

Faster

ASP.NET MVC

Page 43: ASP.NET MVC as the next step in web development

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