PC21: ASP.NET MVC

33
ASP.NET MVC Phil Haack Senior Program Manager Microsoft Corporation PC2 1

Transcript of PC21: ASP.NET MVC

Page 1: PC21: ASP.NET MVC

ASP.NET MVC

Phil HaackSenior Program ManagerMicrosoft Corporation

PC21

Page 2: PC21: ASP.NET MVC

Session Objective(s): Introduce the ASP.NET MVC feature Demonstrate App Building using ASP.NET MVC

Key Takeaways: ASP.NET MVC puts you in full

control of your application ASP.NET MVC is awesome

Session Objectives And Takeaways

Page 3: PC21: ASP.NET MVC

Web 2.0

Why does it seem there are so

few built using ASP.NET

What is Web 2.0?

Marketing hot air?

Or are there some concrete characteristics?

Page 4: PC21: ASP.NET MVC

A Randomly Selected Web 2.0 Website

demo

Page 5: PC21: ASP.NET MVC

What is ASP.NET MVC?

A new Web Application Project type

Simply an option

Not a replacement for WebForms

Builds on top ASP.NET

Manual vs Automatic Transmission

Page 6: PC21: ASP.NET MVC

How was it developed? Transparently

Regular source code releases on CodePlex Previews 1 – 5, Beta thus far. 6 releases! Community feedback via forums, etc…

Agilely 94% Code Coverage/1051 unit tests Daily Triage Meetings and weekly design

meetings Small agile team

Page 7: PC21: ASP.NET MVC

What is MVC?

A design pattern

Acronym for Model ● View ● Controller

Separation of concerns

Page 8: PC21: ASP.NET MVC

What is MVC?

Step 1Incoming request directed to Controller

Request

Controller

Page 9: PC21: ASP.NET MVC

What is MVC?

Step 2Controller processes request and forms a data Model

Controller

Model

Page 10: PC21: ASP.NET MVC

What is MVC?

Step 3Model is passed to View

Controller

View

Page 11: PC21: ASP.NET MVC

What is MVC?

Step 4View transforms Model into appropriate output format

Controller

View

Page 12: PC21: ASP.NET MVC

What is MVC?

Step 5Response is rendered

Response

Controller

View

Page 13: PC21: ASP.NET MVC

“File | New”

demo

Page 14: PC21: ASP.NET MVC

Framework Goals

Frictionless Testability

Tight control over markup

User/SEO friendly URLs

Leverage the benefits of ASP.NET

Conventions and Guidance

Page 15: PC21: ASP.NET MVC

Separation Of Concerns

Each component has one responsibility

SRP – Single Responsibility Principle

DRY – Don’t Repeat Yourelf

More easily testable

Helps with concurrent development

Page 16: PC21: ASP.NET MVC

Extensible

Replace any component of the system

Interface-based architecture

Very few sealed methods / classes

Plays well with others

Page 17: PC21: ASP.NET MVC

Let’s Build an Application!

demo

Page 18: PC21: ASP.NET MVC

WebForms are great …

Mature, proven technology

Scalable

Extensible

Familiar feel to WinForms developers

Page 19: PC21: ASP.NET MVC

… but they have challenges

Abstractions aren’t very abstract

Difficult to test

Lack of control over markup

It does things you didn’t tell it to do

Page 20: PC21: ASP.NET MVC

StackOverflow.com Jeff Atwood

CEOStack Overflow LLC

partner

Page 21: PC21: ASP.NET MVC

Summary

Not a replacement for WebForms All about alternatives

Fundamental Part of the System.Web namespace Same team that builds WebForms

Page 22: PC21: ASP.NET MVC

Providers still work Membership, Caching, Session, etc.

Views leverage .aspx and .ascx But they don’t have to if you don’t want them

to Within System.Web namespace Feature Sharing

SummaryIt’s still ASP.NET

Page 23: PC21: ASP.NET MVC

Replace Any Part with one of your own As simple or complex as it needs to be to

suit your tasks Plays well with others

Want to use NHibernate for models? OK! Want to use Brail for views? OK! Want to use VB for controllers? OK!

SummaryExtensible

Page 24: PC21: ASP.NET MVC

REST-like Fits with the nature of the web

MVC exposes the stateless nature of HTTP Friendlier to humans Friendlier to web crawlers

Search engine optimization (SEO)

SummaryClean URL Structure

Page 25: PC21: ASP.NET MVC

I’ll be at the PDC Lounge Tuesday, October 28 3:00 PM – 6:00 PM if you have more questions.

Breakout Sessions/Chalk Talks: PC30 – ASP.NET Dynamic Data PC31 – ASP.NET and Jquery PC32 – ASP.NET Ajax Futures PC33 – Microsoft Visual Studio: Easing ASP.NET Web PC41 – ASP.NET Cache Extensibility TL20 – EF Futures TL07 – Developing Applications using Data Services TL48 – Microsoft Visual Studio: Web Development

Futures ES15 – Deploying Web Applications with Microsoft IIS

7.0 and the Web Deployment Tool

Related content

Page 26: PC21: ASP.NET MVC

For more information Official sites

Central landing site: http://asp.net/mvc Forums: http://forums.asp.net/1146.aspx

Source available! Source drop: http://codeplex.com/aspnet

Blogs http://haacked.com/ http://weblogs.asp.net/scottgu http://hanselman.com/ http://weblogs.asp.net/leftslipper/

Page 27: PC21: ASP.NET MVC

Please use the microphones provided

Q&A

Page 28: PC21: ASP.NET MVC

28

Evals & Recordings

Please fill

out your

evaluation for

this session at:

This session will be available as a recording at:

www.microsoftpdc.com

Page 29: PC21: ASP.NET MVC

© 2008 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.

Page 30: PC21: ASP.NET MVC
Page 31: PC21: ASP.NET MVC

Choosing Between The Two

Appendix

Page 32: PC21: ASP.NET MVC

You want full control over markup You want a framework that enforces separation

of concerns TDD/Unit Testing is a priority for you Control abstractions get in your way more than

they help You like writing Javascript

You Might be an MVC if…With Apologies to Jeff Foxworthy

Page 33: PC21: ASP.NET MVC

You like programming against the reusable control abstraction that encapsulate UI and logic

You like using the WYSWIG designer and would rather avoid angle brackets

You like keeping logic on the server rather than hand writing Javascript

Unit testing with the MVP pattern is sufficient for your needs

You Might be a WebForm if…With Apologies to Jeff Foxworthy