AMS304: Introduction to the ASP.NET Model View Controller (MVC) Framework Scott Hanselman Eilon Lipton Microsoft Microsoft

Slides:



Advertisements
Similar presentations
Introduction to ASP.NET MVC
Advertisements

INTRODUCTION TO ASP.NET MVC AND EXAMPLE WALKTHROUGH RAJAT ARYA EFECS - OIM DAWG – 4/21/2009 ASP.NET MVC.
Introduction to MVC Adding a View Page NTPCUG Tom Perkins, Ph.D.
Jess Chadwick Website Manager, Infragistics
Fabian Vilers Hands on ASP.NET MVC.
ASP MVC s/mvc-4/getting-started-with- aspnet-mvc4/intro-to-aspnet- mvc-4.
Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models.
Virtual techdays INDIA │ November 2010 ASP.Net MVC Deep Dive Sundararajan S │ Associate Tech Architect, Aditi Technologies.
UNIT-V The MVC architecture and Struts Framework.
Ori Calvo, 2010 “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
Jess Chadwick Lead Code Monkey Infragistics Website Team Todd Snyder Development Team Lead Infragistics Experience Design Group.
CodeIgniter - [Overview]
JavaScript & jQuery the missing manual Chapter 11
Introduction to ASP.NET MVC Blogging Engine in 60 minutes Adnan Masood
ASP.NET and Model View Control Jesper Tørresø ITNET2 F08.
Todd Snyder Development Team Lead Infragistics Experience Design Group.
Marc Ziss Z Consulting Code Name 'Oryx' Web application scaffolding Easy to dynamically display pages based on the data model of.
Building Web Sites with ASP.NET MVC Framework Noam King CTO Sela College
WEB 304 An Overview of ASP.NET and Windows Workflow Foundation Kashif Alam Program Manager Developer Division Microsoft Corporation.
Extending ArcGIS for Server
CS 415 N-Tier Application Development By Umair Ashraf June 28,2013 National University of Computer and Emerging Sciences Lecture # 5 Microsoft MVC3 Architecture.
Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.
Dynamic Languages and the Web Jimmy Schementi Microsoft
MVC A new Web Project Type for ASP.NET. An option. More control over your More control over your A more easily Testable Framework. Not for everyone.
Asp.Net MVC Adnan Masood Jeff Bergman Sean Xiao. Why MVC? Very Clean separation of Concerns Very Clean separation of Concerns Unit Testing Unit Testing.
Building Secure Web Applications With ASP.Net MVC.
© Copyright SELA Software & Education Labs Ltd Baruch Hirsch St. Bnei Brak Israel Noam King CTO Sela College
Getting Started with ASP.NET MVC BRIJ BHUSHAN MISHRA.
ASP.NET MVC in Action Austin Code Camp, 2009 Jeffrey Palermo Chief Technology Officer Headspring Systems.
2 ASP.NET MVC Scott Hanselman Senior Program Manager Microsoft.
Getting started with ASP.NET MVC Dhananjay
ASP.Net MVC Extensibility, scalability and testability Andrew Locatelli Woodcock.
JSP BASICS AND ARCHITECTURE. Goals of JSP Simplify Creation of dynamic pages. Separate Dynamic and Static content.
06 | HTTP Services with Web API Bruno Terkaly | Technical Evangelist Bret Stateham | Technical Evangelist.
Date : 3/04/2010 Web Technology Solutions Class: PHP Web Application Frameworks.
Ruby on Rails Controller of MVC. Routes How we map URIs like /tweets/1 to calling the show method of the Controller.
Introduction  “M” “V” “C” stands for “MODEL” “VIEW” “CONTROLLER”. ASP.NET MVC is an architecture to develop ASP.NET web applications in a different manner.
Virtual techdays INDIA │ 9 th – 11 th January 2011 ASP.Net MVC Sundararajan S │ Associate Tech Architect, Aditi Technologies.
ASP.NET MVC An Introduction. What is MVC The Model-View-Controller (MVC) is an architectural pattern separates an application into three main components:
Scott Guthrie
Virtual techdays INDIA │ 9-11 February 2011 SESSION TITLE Kamala Rajan S │ Technical Manager, Marlabs.
Ruby on Rails. Web Framework for Ruby Designed to make it easier to develop, deploy, and maintain web applications Design with Model-View-Controller –almost.
Introduction to ASP.NET development. Background ASP released in 1996 ASP supported for a minimum 10 years from Windows 8 release ASP.Net 1.0 released.
Intro to MVC5 Bryan Soltis Bit-Wizards - Director of Technology & Research.
WebApi: What is it? How can I use it? Guy In Front of the Whittaker.
Modern Development Technologies in SharePoint SHAREPOINT SATURDAY OMAHA APRIL, 2016.
The New Face of ASP.NET ASP.NET MVC, Razor, and jQuery Ido Flatow | Senior Architect | Sela | This session is.
BIT 286: Web Applications ASP.Net MVC. Objectives Applied MVC overview Controllers Intro to Routing Views ‘Convention over configuration’ Layout files.
A S P. Outline  The introduction of ASP  Why we choose ASP  How ASP works  Basic syntax rule of ASP  ASP’S object model  Limitations of ASP  Summary.
© Copyright SELA software & Education Labs Ltd Baruch Hirsch St.Bnei Brak Israel
Introduction to ASP.NET MVC [Name] [ Address] [Blog URL]
Chapter 1 Getting Started with ASP.NET Objectives Why ASP? To get familiar with our IDE (Integrated Development Environment ), Visual Studio. Understand.
Web Technology Solutions
Introduction to .NET Florin Olariu
An introduction to ASP.Net with MVC Nischal S
Social Media And Global Computing Introduction to The MVC Pattern
ASP MVP Web applications and Razor
ASP.NET MVC Introduction
CO6025 Advanced Programming
Introduction to ASP.NET MVC
MVC Framework, in general.
Driving Experiences via Services Using the Microsoft .NET Framework
ASP.NEXT The ASP.NET 3.5 Extensions
Customizing the SharePoint Mobile Experience
ASP.NET MVC Imran Rashid CTO at ManiWeber Technologies.
ASP.NET and Model View Control
ASP.NEXT Mike Ormond Developer & Platform Group Microsoft Ltd
Concepts in ASP.NET Core App
Introduction to ASP.NET MVC
Presentation transcript:

AMS304: Introduction to the ASP.NET Model View Controller (MVC) Framework Scott Hanselman Eilon Lipton Microsoft Microsoft

INTRO MVC

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 ControllerView

A Little More Detail Model Controller View Browser requests /Products/ Route is determined Controller is activated Method on Controller is invoke Controller does some stuff Renders View, passing in custom ViewData URLs are rendered, pointing to other Controllers

Even More Detail – Request Flow You can futz at each step in the process Request URL Routing Route Route Handler Http Handler Controller View Factory View Response

Demo – Hello MVC World Don’t fall asleep, it’ll be worth it.

HOW IT WORKS MVC

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 { day }); RouteTable.Routes.Add(new Route { Url = "[controller]/[action]/[id]", RouteHandler = typeof(MvcRouteHandler) }); }

Demo – Routing The route less travelled…

HOW TO TEST IT MVC

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!