SlideShare a Scribd company logo
1 of 26
AMS304: Introduction to the
ASP.NET Model View Controller
     (MVC) Framework
Scott Hanselman         Eilon Lipton
   Microsoft              Microsoft
scottha@microsoft.com   elipton@microsoft.com
MVC

INTRO
Goodness

• Maintain Clean Separation of Concerns
  ●   Easy Testing
  ●   Red/Green TDD
  ●   Highly maintainable applications by default
• Extensible and Pluggable
  ●   Support replacing any component of the
      system
Goodness

• Enable clean URLs and HTML
  ●   SEO and REST friendly URL structures

• Great integration within ASP.NET
  ●   Support both static and dynamic languages
What’s the Point?

• This is not Web Forms 4.0
  ●   It’s about alternatives. Car vs. Motorcycle.
• Simple or as complex as you like
  ●   Extend it, add IOC. Or not. If the shoe pinches, don’t
      wear it.
• Fundamental
  ●   Part of System.Web and isn’t going anywhere.
• Plays Well With Others
  ●   Feel free to use NHibernate for Models, Brail for
      Views and Whatever for Controllers. Be Happy.
MVC


             Model




      View           Controller
A Little More Detail

                      •Browser requests /Products/
                      •Route is determined
         Model        •Controller is activated
                      •Method on Controller is invoke
                      •Controller does some stuff
                      •Renders View, passing in
                            custom ViewData
                             •URLs are rendered,
                              pointing to other
  View           Controller   Controllers
Even More Detail – Request Flow
Request    • You can futz at each step
             in the process


 URL       Http
Routing               Controller   Response
          Handler




           Route       View
 Route                               View
          Handler     Factory
Demo – Hello MVC World

  Don’t fall asleep, it’ll be worth it.
MVC

HOW IT WORKS
Basic Controller Handling

• Scenarios, Goals and Design
  ●   URLs route to controller “actions”, not pages –
      mark actions in Controller.
  ●   Controller executes logic, chooses view.
  [ControllerAction]
 public void ShowPost(int id) {
      Post p = PostRepository.GetPostById(id);
      if (p != null) {
          RenderView("showpost", p);
      } else {
          RenderView("nosuchpost", id);
      }
}
Basic Views

• Scenarios, Goals and Design:
  ●   Are for rendering/output.
       • Pre-defined and extensible rendering helpers
  ●   Can use .ASPX, .ASCX, .MASTER, etc.
  ●   Can replace with other view technologies:
       • Template engines (NVelocity, Brail, …).
       • Output formats (images, RSS, JSON, …).
       • Mock out for testing.
  ●   Controller sets data on the View
       • Loosely typed or strongly typed data
URL Routing – Pretty URIs
    • Developers adds Routes to a global RouteTable
    • Mapping creates a RouteData - a bag of key/values
protected void Application_Start(object sender, EventArgs e)
{

RouteTable.Routes.Add(new Route {
  Url = "Blog/bydate/[year]/[month]/[day]",
  Defaults = new { controller="blog", action="showposts" },
  Validation = new { year=@"d{1,4}", month= @"d{1,2}",
                       day = @"d{1,2}"} });

RouteTable.Routes.Add(new Route {
  Url = "[controller]/[action]/[id]",
  RouteHandler = typeof(MvcRouteHandler) });

}
Demo – Routing

    The route less travelled…
MVC

HOW TO TEST IT
Interfaces and TDD

• Mockable Intrinsics
  ●   IHttpContext, IHttpResponse, IHttpRequest
• Extensibility
  ●   IController
  ●   IControllerFactory
  ●   IRouteHandler
  ●   IView
  ●   IViewFactory
Testing Controller Actions
• No requirement to mock out full ASP.NET runtime.
[TestMethod]
public void ShowPostsDisplayPostView() {
    TestPostRepository repository = new TestPostRepository();
    TestViewFactory viewFactory = new TestViewFactory();

    BlogController controller = new BlogController(…);
    controller.ShowPost(2);

    Assert.AreEqual("showpost", viewFactory.LastRequestedView);
    Assert.IsTrue(repository.GetPostByIdWasCalled);
    Assert.AreEqual(2, repository.LastRequestedPostId);
}
Controller Factory
• Scenarios, Goals and Design:
   ●   Hook creation of controller instance
        • Dependency Injection.
        • Object Interception.

public interface IControllerFactory {
    IController CreateController(IHttpContext context,
         RouteData routeData,
         Type controllerType);
}

protected void Application_Start(object s, EventArgs e) {
  ControllerBuilder.Current.SetDefaultControllerFactory(
    typeof(MyControllerFactory));
}
View Factory
• Scenarios, Goals and Design:
   ●   Mock out views for testing
   ●   Replace ASPX with other technologies
public interface IViewFactory {
    IView CreateView(IHttpContext context,
        RouteData routeData,
        string viewName, string layoutName,
        object viewData);
}

Inside controller class:
    ViewFactory = new XmlViewFactory(...);

   RenderView("foo", myData);
Demo – TDD

   Wasn’t this demo technically
     supposed to be first?
Demo – Dynamic Data
       Controls
     Not DDE. Scared you, didn’t I?
Demo – ImageGen

        It’s your thing.
    Do what you wanna do.
Demo – Ruby View Engine
& Python Controller
   It’s a kinder, gentler Microsoft.
          No seriously. Hug?
Demo – XML-RPC

     SOAP is for dorks.
Conclusion

• This is not Web Forms 4.0
  ●   It’s about alternatives. Car vs. Motorcycle.
• Simple or as complex as you like
  ●   Extend it, add IOC. Or not. If the shoe pinches, don’t
      wear it.
• Fundamental
  ●   Part of System.Web and isn’t going anywhere.
• Plays Well With Others
  ●   Feel free to use NHibernate for Models, Brail for
      Views and VB for Controllers. Be Happy.
Your Feedback is Important

Please fill out a session evaluation form and
  either put them in the basket near the exit
      or drop them off at the conference
                registration desk.

                Thank you!

More Related Content

What's hot

Everything you need to know about HTML5 in 15 min
Everything you need to know about HTML5 in 15 minEverything you need to know about HTML5 in 15 min
Everything you need to know about HTML5 in 15 minEdgar Parada
 
JavaLand 2014 - Ankor.io Presentation
JavaLand 2014 - Ankor.io PresentationJavaLand 2014 - Ankor.io Presentation
JavaLand 2014 - Ankor.io Presentationmanolitto
 
Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Sumanth Chinthagunta
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architectureMichael He
 
AngularJS One Day Workshop
AngularJS One Day WorkshopAngularJS One Day Workshop
AngularJS One Day WorkshopShyam Seshadri
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedStéphane Bégaudeau
 
AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)Gary Arora
 
SoCal Code Camp 2011 - ASP.NET 4.5
SoCal Code Camp 2011 - ASP.NET 4.5SoCal Code Camp 2011 - ASP.NET 4.5
SoCal Code Camp 2011 - ASP.NET 4.5Jon Galloway
 
Introduction to Angular js 2.0
Introduction to Angular js 2.0Introduction to Angular js 2.0
Introduction to Angular js 2.0Nagaraju Sangam
 
Angular 2 overview
Angular 2 overviewAngular 2 overview
Angular 2 overviewJesse Warden
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectJadson Santos
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework Yakov Fain
 
Angular2 Development for Java developers
Angular2 Development for Java developersAngular2 Development for Java developers
Angular2 Development for Java developersYakov Fain
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJSInfragistics
 
Angular js tutorial slides
Angular js tutorial slidesAngular js tutorial slides
Angular js tutorial slidessamhelman
 

What's hot (20)

Everything you need to know about HTML5 in 15 min
Everything you need to know about HTML5 in 15 minEverything you need to know about HTML5 in 15 min
Everything you need to know about HTML5 in 15 min
 
Angularjs Basics
Angularjs BasicsAngularjs Basics
Angularjs Basics
 
JavaLand 2014 - Ankor.io Presentation
JavaLand 2014 - Ankor.io PresentationJavaLand 2014 - Ankor.io Presentation
JavaLand 2014 - Ankor.io Presentation
 
Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architecture
 
AngularJS One Day Workshop
AngularJS One Day WorkshopAngularJS One Day Workshop
AngularJS One Day Workshop
 
Angular js
Angular jsAngular js
Angular js
 
Introduction to Angular JS
Introduction to Angular JSIntroduction to Angular JS
Introduction to Angular JS
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
 
AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)
 
SoCal Code Camp 2011 - ASP.NET 4.5
SoCal Code Camp 2011 - ASP.NET 4.5SoCal Code Camp 2011 - ASP.NET 4.5
SoCal Code Camp 2011 - ASP.NET 4.5
 
Introduction to Angular js 2.0
Introduction to Angular js 2.0Introduction to Angular js 2.0
Introduction to Angular js 2.0
 
Angular 2 overview
Angular 2 overviewAngular 2 overview
Angular 2 overview
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete project
 
Angular js
Angular jsAngular js
Angular js
 
Angular js
Angular jsAngular js
Angular js
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework
 
Angular2 Development for Java developers
Angular2 Development for Java developersAngular2 Development for Java developers
Angular2 Development for Java developers
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJS
 
Angular js tutorial slides
Angular js tutorial slidesAngular js tutorial slides
Angular js tutorial slides
 

Viewers also liked

Media evaluation Q.1
Media evaluation Q.1Media evaluation Q.1
Media evaluation Q.1phoebeconnie
 
Apresentação Oficial da Youphi
Apresentação Oficial da YouphiApresentação Oficial da Youphi
Apresentação Oficial da YouphiIvan Caixeta
 
An+ülisis de un mensaje individual 2014
An+ülisis de un mensaje individual 2014An+ülisis de un mensaje individual 2014
An+ülisis de un mensaje individual 2014hfgedszxfcvb
 
Flat plan
Flat planFlat plan
Flat planLBondi9
 
Weekly Stock Market Tips
Weekly Stock Market TipsWeekly Stock Market Tips
Weekly Stock Market TipsNisha Sharma
 
Kelly Briddes Edu 105 June 22, 2015 Dr. Keenan
Kelly Briddes Edu 105 June 22, 2015 Dr. KeenanKelly Briddes Edu 105 June 22, 2015 Dr. Keenan
Kelly Briddes Edu 105 June 22, 2015 Dr. KeenanKelly Briddes
 
Customized Stainless Steel Modular Kitchens by Arttdinox
Customized Stainless Steel Modular Kitchens by ArttdinoxCustomized Stainless Steel Modular Kitchens by Arttdinox
Customized Stainless Steel Modular Kitchens by ArttdinoxRajat Tyagi
 

Viewers also liked (13)

Juego pacman 1
Juego pacman 1Juego pacman 1
Juego pacman 1
 
Media evaluation Q.1
Media evaluation Q.1Media evaluation Q.1
Media evaluation Q.1
 
Apresentação Oficial da Youphi
Apresentação Oficial da YouphiApresentação Oficial da Youphi
Apresentação Oficial da Youphi
 
Auto replies
Auto repliesAuto replies
Auto replies
 
An+ülisis de un mensaje individual 2014
An+ülisis de un mensaje individual 2014An+ülisis de un mensaje individual 2014
An+ülisis de un mensaje individual 2014
 
Felicitacion.
Felicitacion.Felicitacion.
Felicitacion.
 
Flat plan
Flat planFlat plan
Flat plan
 
Weekly Stock Market Tips
Weekly Stock Market TipsWeekly Stock Market Tips
Weekly Stock Market Tips
 
Ask the Prof
Ask the ProfAsk the Prof
Ask the Prof
 
Kelly Briddes Edu 105 June 22, 2015 Dr. Keenan
Kelly Briddes Edu 105 June 22, 2015 Dr. KeenanKelly Briddes Edu 105 June 22, 2015 Dr. Keenan
Kelly Briddes Edu 105 June 22, 2015 Dr. Keenan
 
Wall jobs pitch
Wall jobs pitchWall jobs pitch
Wall jobs pitch
 
Dai Gelinlik
Dai GelinlikDai Gelinlik
Dai Gelinlik
 
Customized Stainless Steel Modular Kitchens by Arttdinox
Customized Stainless Steel Modular Kitchens by ArttdinoxCustomized Stainless Steel Modular Kitchens by Arttdinox
Customized Stainless Steel Modular Kitchens by Arttdinox
 

Similar to Hanselman lipton asp_connections_ams304_mvc

Asp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantAsp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantNitin Sawant
 
Asp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design PatternAsp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design Patternmaddinapudi
 
Fast Track introduction to ASP.NET MVC
Fast Track introduction to ASP.NET MVCFast Track introduction to ASP.NET MVC
Fast Track introduction to ASP.NET MVCAnkit Kashyap
 
Play with azure functions
Play with azure functionsPlay with azure functions
Play with azure functionsBaskar rao Dsn
 
2011 NetUG HH: ASP.NET MVC & HTML 5
2011 NetUG HH: ASP.NET MVC & HTML 52011 NetUG HH: ASP.NET MVC & HTML 5
2011 NetUG HH: ASP.NET MVC & HTML 5Daniel Fisher
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015Hossein Zahed
 
Azure Functions in Action #OrlandoCC
Azure Functions in Action #OrlandoCCAzure Functions in Action #OrlandoCC
Azure Functions in Action #OrlandoCCBaskar rao Dsn
 
Azure Functions in Action #CodePaLOUsa
Azure Functions in Action #CodePaLOUsaAzure Functions in Action #CodePaLOUsa
Azure Functions in Action #CodePaLOUsaBaskar rao Dsn
 
Era of server less computing
Era of server less computingEra of server less computing
Era of server less computingBaskar rao Dsn
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_HourDilip Patel
 
Behat Workshop at WeLovePHP
Behat Workshop at WeLovePHPBehat Workshop at WeLovePHP
Behat Workshop at WeLovePHPMarcos Quesada
 
Era of server less computing final
Era of server less computing finalEra of server less computing final
Era of server less computing finalBaskar rao Dsn
 
Building an Angular 2 App
Building an Angular 2 AppBuilding an Angular 2 App
Building an Angular 2 AppFelix Gessert
 
ZZ BC#7 asp.net mvc practice and guideline by NineMvp
ZZ BC#7 asp.net mvc practice and guideline by NineMvpZZ BC#7 asp.net mvc practice and guideline by NineMvp
ZZ BC#7 asp.net mvc practice and guideline by NineMvpChalermpon Areepong
 
Creating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSCreating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSGunnar Hillert
 
Automating your php infrastructure with the zend server api
Automating your php infrastructure with the zend server apiAutomating your php infrastructure with the zend server api
Automating your php infrastructure with the zend server apiYonni Mendes
 
#SPSBrussels 2017 vincent biret #azure #functions microsoft #flow
#SPSBrussels 2017 vincent biret #azure #functions microsoft #flow#SPSBrussels 2017 vincent biret #azure #functions microsoft #flow
#SPSBrussels 2017 vincent biret #azure #functions microsoft #flowVincent Biret
 
Introduction to Microsoft Flow and Azure Functions
Introduction to Microsoft Flow and Azure FunctionsIntroduction to Microsoft Flow and Azure Functions
Introduction to Microsoft Flow and Azure FunctionsBIWUG
 

Similar to Hanselman lipton asp_connections_ams304_mvc (20)

Asp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantAsp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin Sawant
 
Asp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design PatternAsp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design Pattern
 
Fast Track introduction to ASP.NET MVC
Fast Track introduction to ASP.NET MVCFast Track introduction to ASP.NET MVC
Fast Track introduction to ASP.NET MVC
 
Play with azure functions
Play with azure functionsPlay with azure functions
Play with azure functions
 
2011 NetUG HH: ASP.NET MVC & HTML 5
2011 NetUG HH: ASP.NET MVC & HTML 52011 NetUG HH: ASP.NET MVC & HTML 5
2011 NetUG HH: ASP.NET MVC & HTML 5
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015
 
Azure Functions in Action #OrlandoCC
Azure Functions in Action #OrlandoCCAzure Functions in Action #OrlandoCC
Azure Functions in Action #OrlandoCC
 
Azure Functions in Action #CodePaLOUsa
Azure Functions in Action #CodePaLOUsaAzure Functions in Action #CodePaLOUsa
Azure Functions in Action #CodePaLOUsa
 
Sitecore mvc
Sitecore mvcSitecore mvc
Sitecore mvc
 
Era of server less computing
Era of server less computingEra of server less computing
Era of server less computing
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
 
Behat Workshop at WeLovePHP
Behat Workshop at WeLovePHPBehat Workshop at WeLovePHP
Behat Workshop at WeLovePHP
 
Introduction to AngularJs
Introduction to AngularJsIntroduction to AngularJs
Introduction to AngularJs
 
Era of server less computing final
Era of server less computing finalEra of server less computing final
Era of server less computing final
 
Building an Angular 2 App
Building an Angular 2 AppBuilding an Angular 2 App
Building an Angular 2 App
 
ZZ BC#7 asp.net mvc practice and guideline by NineMvp
ZZ BC#7 asp.net mvc practice and guideline by NineMvpZZ BC#7 asp.net mvc practice and guideline by NineMvp
ZZ BC#7 asp.net mvc practice and guideline by NineMvp
 
Creating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSCreating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJS
 
Automating your php infrastructure with the zend server api
Automating your php infrastructure with the zend server apiAutomating your php infrastructure with the zend server api
Automating your php infrastructure with the zend server api
 
#SPSBrussels 2017 vincent biret #azure #functions microsoft #flow
#SPSBrussels 2017 vincent biret #azure #functions microsoft #flow#SPSBrussels 2017 vincent biret #azure #functions microsoft #flow
#SPSBrussels 2017 vincent biret #azure #functions microsoft #flow
 
Introduction to Microsoft Flow and Azure Functions
Introduction to Microsoft Flow and Azure FunctionsIntroduction to Microsoft Flow and Azure Functions
Introduction to Microsoft Flow and Azure Functions
 

Recently uploaded

Call Girl in Low Price Delhi Punjabi Bagh 9711199012
Call Girl in Low Price Delhi Punjabi Bagh  9711199012Call Girl in Low Price Delhi Punjabi Bagh  9711199012
Call Girl in Low Price Delhi Punjabi Bagh 9711199012sapnasaifi408
 
Vip Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
Vip  Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...Vip  Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
Vip Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...shivangimorya083
 
VIP High Profile Call Girls Jamshedpur Aarushi 8250192130 Independent Escort ...
VIP High Profile Call Girls Jamshedpur Aarushi 8250192130 Independent Escort ...VIP High Profile Call Girls Jamshedpur Aarushi 8250192130 Independent Escort ...
VIP High Profile Call Girls Jamshedpur Aarushi 8250192130 Independent Escort ...Suhani Kapoor
 
VIP Call Girls in Jamshedpur Aarohi 8250192130 Independent Escort Service Jam...
VIP Call Girls in Jamshedpur Aarohi 8250192130 Independent Escort Service Jam...VIP Call Girls in Jamshedpur Aarohi 8250192130 Independent Escort Service Jam...
VIP Call Girls in Jamshedpur Aarohi 8250192130 Independent Escort Service Jam...Suhani Kapoor
 
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...Suhani Kapoor
 
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service Bhiwandi
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service BhiwandiVIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service Bhiwandi
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service BhiwandiSuhani Kapoor
 
CFO_SB_Career History_Multi Sector Experience
CFO_SB_Career History_Multi Sector ExperienceCFO_SB_Career History_Multi Sector Experience
CFO_SB_Career History_Multi Sector ExperienceSanjay Bokadia
 
Production Day 1.pptxjvjbvbcbcb bj bvcbj
Production Day 1.pptxjvjbvbcbcb bj bvcbjProduction Day 1.pptxjvjbvbcbcb bj bvcbj
Production Day 1.pptxjvjbvbcbcb bj bvcbjLewisJB
 
Delhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
CALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual serviceanilsa9823
 
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证女王大学硕士毕业证成绩单(加急办理)认证海外毕业证
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证obuhobo
 
VIP Call Girl Bhilai Aashi 8250192130 Independent Escort Service Bhilai
VIP Call Girl Bhilai Aashi 8250192130 Independent Escort Service BhilaiVIP Call Girl Bhilai Aashi 8250192130 Independent Escort Service Bhilai
VIP Call Girl Bhilai Aashi 8250192130 Independent Escort Service BhilaiSuhani Kapoor
 
Dark Dubai Call Girls O525547819 Skin Call Girls Dubai
Dark Dubai Call Girls O525547819 Skin Call Girls DubaiDark Dubai Call Girls O525547819 Skin Call Girls Dubai
Dark Dubai Call Girls O525547819 Skin Call Girls Dubaikojalkojal131
 
Dubai Call Girls Starlet O525547819 Call Girls Dubai Showen Dating
Dubai Call Girls Starlet O525547819 Call Girls Dubai Showen DatingDubai Call Girls Starlet O525547819 Call Girls Dubai Showen Dating
Dubai Call Girls Starlet O525547819 Call Girls Dubai Showen Datingkojalkojal131
 
Business Development and Product Strategy for a SME named SARL based in Leban...
Business Development and Product Strategy for a SME named SARL based in Leban...Business Development and Product Strategy for a SME named SARL based in Leban...
Business Development and Product Strategy for a SME named SARL based in Leban...Soham Mondal
 
Neha +91-9537192988-Friendly Ahmedabad Call Girls has Complete Authority for ...
Neha +91-9537192988-Friendly Ahmedabad Call Girls has Complete Authority for ...Neha +91-9537192988-Friendly Ahmedabad Call Girls has Complete Authority for ...
Neha +91-9537192988-Friendly Ahmedabad Call Girls has Complete Authority for ...Niya Khan
 
Dubai Call Girls Demons O525547819 Call Girls IN DUbai Natural Big Boody
Dubai Call Girls Demons O525547819 Call Girls IN DUbai Natural Big BoodyDubai Call Girls Demons O525547819 Call Girls IN DUbai Natural Big Boody
Dubai Call Girls Demons O525547819 Call Girls IN DUbai Natural Big Boodykojalkojal131
 
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Service
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Service
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Servicejennyeacort
 
(Call Girls) in Lucknow Real photos of Female Escorts 👩🏼‍❤️‍💋‍👩🏻 8923113531 ➝...
(Call Girls) in Lucknow Real photos of Female Escorts 👩🏼‍❤️‍💋‍👩🏻 8923113531 ➝...(Call Girls) in Lucknow Real photos of Female Escorts 👩🏼‍❤️‍💋‍👩🏻 8923113531 ➝...
(Call Girls) in Lucknow Real photos of Female Escorts 👩🏼‍❤️‍💋‍👩🏻 8923113531 ➝...gurkirankumar98700
 

Recently uploaded (20)

Call Girl in Low Price Delhi Punjabi Bagh 9711199012
Call Girl in Low Price Delhi Punjabi Bagh  9711199012Call Girl in Low Price Delhi Punjabi Bagh  9711199012
Call Girl in Low Price Delhi Punjabi Bagh 9711199012
 
Vip Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
Vip  Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...Vip  Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
Vip Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
 
Call Girls In Prashant Vihar꧁❤ 🔝 9953056974🔝❤꧂ Escort ServiCe
Call Girls In Prashant Vihar꧁❤ 🔝 9953056974🔝❤꧂ Escort ServiCeCall Girls In Prashant Vihar꧁❤ 🔝 9953056974🔝❤꧂ Escort ServiCe
Call Girls In Prashant Vihar꧁❤ 🔝 9953056974🔝❤꧂ Escort ServiCe
 
VIP High Profile Call Girls Jamshedpur Aarushi 8250192130 Independent Escort ...
VIP High Profile Call Girls Jamshedpur Aarushi 8250192130 Independent Escort ...VIP High Profile Call Girls Jamshedpur Aarushi 8250192130 Independent Escort ...
VIP High Profile Call Girls Jamshedpur Aarushi 8250192130 Independent Escort ...
 
VIP Call Girls in Jamshedpur Aarohi 8250192130 Independent Escort Service Jam...
VIP Call Girls in Jamshedpur Aarohi 8250192130 Independent Escort Service Jam...VIP Call Girls in Jamshedpur Aarohi 8250192130 Independent Escort Service Jam...
VIP Call Girls in Jamshedpur Aarohi 8250192130 Independent Escort Service Jam...
 
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...
 
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service Bhiwandi
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service BhiwandiVIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service Bhiwandi
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service Bhiwandi
 
CFO_SB_Career History_Multi Sector Experience
CFO_SB_Career History_Multi Sector ExperienceCFO_SB_Career History_Multi Sector Experience
CFO_SB_Career History_Multi Sector Experience
 
Production Day 1.pptxjvjbvbcbcb bj bvcbj
Production Day 1.pptxjvjbvbcbcb bj bvcbjProduction Day 1.pptxjvjbvbcbcb bj bvcbj
Production Day 1.pptxjvjbvbcbcb bj bvcbj
 
Delhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
CALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual service
 
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证女王大学硕士毕业证成绩单(加急办理)认证海外毕业证
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证
 
VIP Call Girl Bhilai Aashi 8250192130 Independent Escort Service Bhilai
VIP Call Girl Bhilai Aashi 8250192130 Independent Escort Service BhilaiVIP Call Girl Bhilai Aashi 8250192130 Independent Escort Service Bhilai
VIP Call Girl Bhilai Aashi 8250192130 Independent Escort Service Bhilai
 
Dark Dubai Call Girls O525547819 Skin Call Girls Dubai
Dark Dubai Call Girls O525547819 Skin Call Girls DubaiDark Dubai Call Girls O525547819 Skin Call Girls Dubai
Dark Dubai Call Girls O525547819 Skin Call Girls Dubai
 
Dubai Call Girls Starlet O525547819 Call Girls Dubai Showen Dating
Dubai Call Girls Starlet O525547819 Call Girls Dubai Showen DatingDubai Call Girls Starlet O525547819 Call Girls Dubai Showen Dating
Dubai Call Girls Starlet O525547819 Call Girls Dubai Showen Dating
 
Business Development and Product Strategy for a SME named SARL based in Leban...
Business Development and Product Strategy for a SME named SARL based in Leban...Business Development and Product Strategy for a SME named SARL based in Leban...
Business Development and Product Strategy for a SME named SARL based in Leban...
 
Neha +91-9537192988-Friendly Ahmedabad Call Girls has Complete Authority for ...
Neha +91-9537192988-Friendly Ahmedabad Call Girls has Complete Authority for ...Neha +91-9537192988-Friendly Ahmedabad Call Girls has Complete Authority for ...
Neha +91-9537192988-Friendly Ahmedabad Call Girls has Complete Authority for ...
 
Dubai Call Girls Demons O525547819 Call Girls IN DUbai Natural Big Boody
Dubai Call Girls Demons O525547819 Call Girls IN DUbai Natural Big BoodyDubai Call Girls Demons O525547819 Call Girls IN DUbai Natural Big Boody
Dubai Call Girls Demons O525547819 Call Girls IN DUbai Natural Big Boody
 
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Service
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Service
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Service
 
(Call Girls) in Lucknow Real photos of Female Escorts 👩🏼‍❤️‍💋‍👩🏻 8923113531 ➝...
(Call Girls) in Lucknow Real photos of Female Escorts 👩🏼‍❤️‍💋‍👩🏻 8923113531 ➝...(Call Girls) in Lucknow Real photos of Female Escorts 👩🏼‍❤️‍💋‍👩🏻 8923113531 ➝...
(Call Girls) in Lucknow Real photos of Female Escorts 👩🏼‍❤️‍💋‍👩🏻 8923113531 ➝...
 

Hanselman lipton asp_connections_ams304_mvc

  • 1. AMS304: Introduction to the ASP.NET Model View Controller (MVC) Framework Scott Hanselman Eilon Lipton Microsoft Microsoft scottha@microsoft.com elipton@microsoft.com
  • 3. Goodness • Maintain Clean Separation of Concerns ● Easy Testing ● Red/Green TDD ● Highly maintainable applications by default • Extensible and Pluggable ● Support replacing any component of the system
  • 4. Goodness • Enable clean URLs and HTML ● SEO and REST friendly URL structures • Great integration within ASP.NET ● Support both static and dynamic languages
  • 5. What’s the Point? • This is not Web Forms 4.0 ● It’s about alternatives. Car vs. Motorcycle. • Simple or as complex as you like ● Extend it, add IOC. Or not. If the shoe pinches, don’t wear it. • Fundamental ● Part of System.Web and isn’t going anywhere. • Plays Well With Others ● Feel free to use NHibernate for Models, Brail for Views and Whatever for Controllers. Be Happy.
  • 6. MVC Model View Controller
  • 7. A Little More Detail •Browser requests /Products/ •Route is determined Model •Controller is activated •Method on Controller is invoke •Controller does some stuff •Renders View, passing in custom ViewData •URLs are rendered, pointing to other View Controller Controllers
  • 8. Even More Detail – Request Flow Request • You can futz at each step in the process URL Http Routing Controller Response Handler Route View Route View Handler Factory
  • 9. Demo – Hello MVC World Don’t fall asleep, it’ll be worth it.
  • 11. Basic Controller Handling • Scenarios, Goals and Design ● URLs route to controller “actions”, not pages – mark actions in Controller. ● Controller executes logic, chooses view. [ControllerAction] public void ShowPost(int id) { Post p = PostRepository.GetPostById(id); if (p != null) { RenderView("showpost", p); } else { RenderView("nosuchpost", id); } }
  • 12. Basic Views • Scenarios, Goals and Design: ● Are for rendering/output. • Pre-defined and extensible rendering helpers ● Can use .ASPX, .ASCX, .MASTER, etc. ● Can replace with other view technologies: • Template engines (NVelocity, Brail, …). • Output formats (images, RSS, JSON, …). • Mock out for testing. ● Controller sets data on the View • Loosely typed or strongly typed data
  • 13. URL Routing – Pretty URIs • Developers adds Routes to a global RouteTable • Mapping creates a RouteData - a bag of key/values protected void Application_Start(object sender, EventArgs e) { RouteTable.Routes.Add(new Route { Url = "Blog/bydate/[year]/[month]/[day]", Defaults = new { controller="blog", action="showposts" }, Validation = new { year=@"d{1,4}", month= @"d{1,2}", day = @"d{1,2}"} }); RouteTable.Routes.Add(new Route { Url = "[controller]/[action]/[id]", RouteHandler = typeof(MvcRouteHandler) }); }
  • 14. Demo – Routing The route less travelled…
  • 16. Interfaces and TDD • Mockable Intrinsics ● IHttpContext, IHttpResponse, IHttpRequest • Extensibility ● IController ● IControllerFactory ● IRouteHandler ● IView ● IViewFactory
  • 17. Testing Controller Actions • No requirement to mock out full ASP.NET runtime. [TestMethod] public void ShowPostsDisplayPostView() { TestPostRepository repository = new TestPostRepository(); TestViewFactory viewFactory = new TestViewFactory(); BlogController controller = new BlogController(…); controller.ShowPost(2); Assert.AreEqual("showpost", viewFactory.LastRequestedView); Assert.IsTrue(repository.GetPostByIdWasCalled); Assert.AreEqual(2, repository.LastRequestedPostId); }
  • 18. Controller Factory • Scenarios, Goals and Design: ● Hook creation of controller instance • Dependency Injection. • Object Interception. public interface IControllerFactory { IController CreateController(IHttpContext context, RouteData routeData, Type controllerType); } protected void Application_Start(object s, EventArgs e) { ControllerBuilder.Current.SetDefaultControllerFactory( typeof(MyControllerFactory)); }
  • 19. View Factory • Scenarios, Goals and Design: ● Mock out views for testing ● Replace ASPX with other technologies public interface IViewFactory { IView CreateView(IHttpContext context, RouteData routeData, string viewName, string layoutName, object viewData); } Inside controller class: ViewFactory = new XmlViewFactory(...); RenderView("foo", myData);
  • 20. Demo – TDD Wasn’t this demo technically supposed to be first?
  • 21. Demo – Dynamic Data Controls Not DDE. Scared you, didn’t I?
  • 22. Demo – ImageGen It’s your thing. Do what you wanna do.
  • 23. Demo – Ruby View Engine & Python Controller It’s a kinder, gentler Microsoft. No seriously. Hug?
  • 24. Demo – XML-RPC SOAP is for dorks.
  • 25. Conclusion • This is not Web Forms 4.0 ● It’s about alternatives. Car vs. Motorcycle. • Simple or as complex as you like ● Extend it, add IOC. Or not. If the shoe pinches, don’t wear it. • Fundamental ● Part of System.Web and isn’t going anywhere. • Plays Well With Others ● Feel free to use NHibernate for Models, Brail for Views and VB for Controllers. Be Happy.
  • 26. Your Feedback is Important Please fill out a session evaluation form and either put them in the basket near the exit or drop them off at the conference registration desk. Thank you!

Editor's Notes

  1. Been around since Xerox in 1979
  2. Been around since Xerox in 1979
  3. Been around since Xerox in 1979
  4. Write a blog
  5. Write a blog
  6. Write a blog
  7. Write a blog
  8. Write a blog
  9. Write a blog