SlideShare a Scribd company logo
1 of 32
Venketash (Pat) Ramadass
Systems Architect & Managing Director
emediaIT
pat.ramadass@emediait.com
http://patramadass.emediait.com
Separation of Concerns


    MVC


    ASP.NET MVC


    Demonstrations of building simple ASP.NET

    MVC functionality

    Questions

Presentation logic, business logic and data

    access logic are mixed together too often
     Business logic code within the User Interface
     Unmanagable code, goes against good OO
     principles

    Proper Separation of Concerns (SoC) solves

    this by de-coupling the overall architecture
Stands for Model-View-Controller


    It is a design pattern for software development


    Designed to promote and enforce Separation

    of Concerns
     Model – Data Access and Business Logic
     View – User Interface
     Controller – Handles User Interaction and Model
     Manipulation
User
User Interface           Generates Events




   View(s)                 Controller(s)




Provides Data             Manipulates
                 Model
MVC Framework which Microsoft is adding to

    ASP.NET

    Alternative to ASP.NET, not a replacement



    Can combine both in a single solution



    Currently in public beta, but there are

    production systems using it already
Clear separation of concerns (SoC)



    Testability - support for TDD



    Fine-grained control over HTML and

    JavaScript

    Intuitive URLs (Routing) – SEO Friendly

Functionality                                           Webforms                          ASP.NET MVC
URLs                                               Page names and URL                         Routing Programmatically -
                                                   Rewriting                                  REST
Event Driven                                       Yes                                        No
Stateful                                           Yes (Viewstate)                            No
Easily Unit Tested                                 No                                         Yes
Abstraction from HTML                              Yes                                        No
Exact control over HTML                            No                                         Yes
Supports ORM                                       Yes                                        Yes
Easy use of Third Party UI                         Yes                                        Partial (No state/postback
controls                                                                                      controls only)
Works on Linux/Mono                                Yes (Partial)                              Not yet supported, but can be
                                                                                              made to work
The above is not intended to be a complete list, it simply highlights some key differences.
6




                                                                                       View
                                             Routing
                                                                    Controller
                            1                                   2                5
                                              Rules




                                                                        3
1. HTTP Request

2. ASP.NET MVC Framework evaluates URL against registered
Routing Rules and forwards the request to a matching Controller
                                                                      Model          Data Store
                                                                                 4
3. Controller calls Model to build ViewData, if required

4. The Model returns the requested Data to the Controller

5. The Controller selects a View and passes the Model to the View

6. View renders and returns HTTP Response
Creating a new MVC Project


    Folder Structure


    Sample application included in ASP.NET MVC

    Application Template

    A URL does not equal a page


    Understanding URL Routing

URL: /Product/Details/3

     This URL is parsed into three parts like this:
      ▪ Controller = ProductController
      ▪ Action = Details
      ▪ Id = 3

     The request is therefore routed to the Details() action
      on the ProductController class, with a Id parameter of
      3

     Notice that the suffix Controller is tacked on to the
      end of the Controller parameter.
Default Route

     Default Controller: HomeController
     Default Action: Index
     Default Id: Empty String

    URL: /Employee

     This URL is parsed into three parts like this:
      ▪ Controller = EmployeeController
      ▪ Action = Index
      ▪ Id = “”

     The request is therefore routed to the Index() action on
      the EmployeeController class
Default Route

     Default Controller: HomeController
     Default Action: Index
     Default Id: Empty String


    URL: http://localhost, i.e. Without supplying a

    further URL
In a blog application, you may want to handle

    incoming requests that look like: /Archive/12-
    25-2009. For this you would need a Custom
    Route.

    The order in which routes are added is

    important
A controller should only contain the bare minimum of logic

    required to return the right view or redirect the user to another
    action.
    A controller is just a Class, inherits from

    System.Web.Mvc.Controller
    HomeController.cs has 2 methods called Index() and About(),

    these are the actions it exposes.
    The URL /Home/Index invokes the HomeController.Index()

    method and the URL /Home/About invokes the
    HomeController.About() method.
    Any public method in a controller is exposed as a controller

    action.
A method used as a controller action cannot be overloaded or static


    A controller action returns action result.


    Six standard types of action results:

     ViewResult – Represents HTML and markup.
     EmptyResult – Represents no result.
     RedirectResult – Represents a redirection to a new URL.
     RedirectToRouteResult – Represents a redirection to a new controller action.
     JsonResult – Represents a JavaScript Object Notation result that can be used
      in an AJAX application.
     ContentResult – Represents a text result.

    ContentResult is useful for returning plain text such as dates, integers etc

Instead of returning an action result directly, you

    normally call one of the following methods on
    the Controller base class:

     View – Returns a ViewResult action result.
     Redirect – Returns a RedirectResult action result.
     RedirectToAction – Returns a RedirectToRouteResult
      action result.
     RedirectToRoute – Returns a RedirectToRouteResult
      action result.
     Json – Returns a JsonResult action result.
     Content – Returns a ContentResult action result.
Modifying ActionResult

A view should contain only logic related to generating the user

    interface.
    A view contains the HTML markup and content that is sent to the

    browser. A view is the equivalent of a page.
    In general, to return a view for a controller action, you must create

    a subfolder in the Views folder with the same name as your
    controller. Within the subfolder, you must create an .aspx file with
    the same name as the controller action.
    The HomeController.Index() action returns a view located at the

    following path: ViewsHomeIndex.aspx
    The HomeController.About() action returns a view located at the

    following path: ViewsHomeAbout.aspx
Adding a new View Page



    Using HTML Helpers to Generate View

    Content

    Using View Data to Pass Data to a View

An MVC model contains all of your

    application logic that is not contained in a
    view or a controller. This should be all of
    your business logic and data access logic

    Aim for fat models and skinny controllers

Create a new Database



    Create a new Model



    Using LINQ in Controller Actions



    Using the Repository Pattern

Why TDD?



    Testing the View returned by a Controller



    Testing the View Data returned by a

    Controller

    Testing the Action Result returned by a

    Controller
ASP.NET 3.5 Installed



    Visual Studio 2008



    Microsoft ASP.NET MVC Installed

     Download the current Beta
ASP.NET 3.5 Installed



    Visual Studio 2008



    Microsoft ASP.NET MVC Installed

     Download the current Beta
More Involved Examples

     Add/Edit/Delete and use of Server Controls
      ▪ Email me if you would like information on this

    Custom HTML Helpers

     You can create your own Helper Classes and Extension
      Methods which return formatted HTML strings

    Unity Dependency Injection / IoC Container

     Framework for Dependency Injection and Controller
      Factories
     Stand alone version and bundled with Enterprise Library
      4.0
Using Partials as Templates for formatting/rendering

     For example a template for how a Movie is rendered
     HTML.RenderPartial(string partialViewName, object
      Model)

    Action Filters

     Attributes that can be applied to a Controller Action or
      entire Controller
      ▪   Authorization
      ▪   Action Result
      ▪   Exception
      ▪   Custom
     For example for Logging/Tracing
Upgrading existing code will take a long time, better

    for Greenfields projects
    For now, applications which require richer user

    interfaces will require more work with MVC
     Third party UI library vendors have started developing and
      releasing updated controls

    Some SEO issues, may require URL rewrite engine,

    but can be done
    Not officially supported on pre Windows Server

    2003/IIS 6, but can work
If you are developing a new system it is worth

    evaluating the pros and cons, it is not a silver
    bullet however
    ASP.NET MVC is much more in line with what is

    happening elsewhere in the industry, for
    example Ruby on Rails
    We feel that the Pros outweigh the Cons in

    general and are implementing ASP.NET MVC in
    our new Web Applications wherever possible
http://www.asp.net/mvc/

       Official Site

    http://weblogs.asp.net/scottgu

       Scott Guthrie

    http://www.hanselman.com/

       Scott Hanselman

    http://quickstarts.asp.net/previews/mvc

       Videos, Examples, Blogs

    http://martinfowler.com/articles/injection.html

       Repository/Dependency Injection Pattern

    http://www.pnpguidance.net/Category/Unity.aspx

       Unity

    http://patramadass.emediait.com

       This presentation, example code
ASP.NET MVC - Whats The Big Deal

More Related Content

What's hot

JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)Alexander Casall
 
AngularJS Beginner Day One
AngularJS Beginner Day OneAngularJS Beginner Day One
AngularJS Beginner Day OneTroy Miles
 
APEX Behind the Scenes by Scott Spendolini
APEX Behind the Scenes by Scott SpendoliniAPEX Behind the Scenes by Scott Spendolini
APEX Behind the Scenes by Scott SpendoliniEnkitec
 
Out of box page object design pattern, java
Out of box page object design pattern, javaOut of box page object design pattern, java
Out of box page object design pattern, javaCOMAQA.BY
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVCMaarten Balliauw
 
Selenium XPath Performance Problems in IE
Selenium XPath Performance Problems in IESelenium XPath Performance Problems in IE
Selenium XPath Performance Problems in IEClever Moe
 
Selenium withnet
Selenium withnetSelenium withnet
Selenium withnetVlad Maniak
 
Apex behind the scenes
Apex behind the scenesApex behind the scenes
Apex behind the scenesEnkitec
 
BDD with JBehave and Selenium
BDD with JBehave and SeleniumBDD with JBehave and Selenium
BDD with JBehave and SeleniumNikolay Vasilev
 
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
 
Wicket Next (1.4/1.5)
Wicket Next (1.4/1.5)Wicket Next (1.4/1.5)
Wicket Next (1.4/1.5)jcompagner
 
Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran TochAdil Jafri
 
Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008
Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008
Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008Baruch Sadogursky
 
Testing Spring MVC and REST Web Applications
Testing Spring MVC and REST Web ApplicationsTesting Spring MVC and REST Web Applications
Testing Spring MVC and REST Web ApplicationsSam Brannen
 
Apache Wicket Web Framework
Apache Wicket Web FrameworkApache Wicket Web Framework
Apache Wicket Web FrameworkLuther Baker
 

What's hot (20)

JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)
 
AngularJS Beginner Day One
AngularJS Beginner Day OneAngularJS Beginner Day One
AngularJS Beginner Day One
 
JavaFX Pitfalls
JavaFX PitfallsJavaFX Pitfalls
JavaFX Pitfalls
 
APEX Behind the Scenes by Scott Spendolini
APEX Behind the Scenes by Scott SpendoliniAPEX Behind the Scenes by Scott Spendolini
APEX Behind the Scenes by Scott Spendolini
 
Out of box page object design pattern, java
Out of box page object design pattern, javaOut of box page object design pattern, java
Out of box page object design pattern, java
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
Selenium XPath Performance Problems in IE
Selenium XPath Performance Problems in IESelenium XPath Performance Problems in IE
Selenium XPath Performance Problems in IE
 
Selenium withnet
Selenium withnetSelenium withnet
Selenium withnet
 
Apex behind the scenes
Apex behind the scenesApex behind the scenes
Apex behind the scenes
 
BDD with JBehave and Selenium
BDD with JBehave and SeleniumBDD with JBehave and Selenium
BDD with JBehave and Selenium
 
JavaFX Advanced
JavaFX AdvancedJavaFX Advanced
JavaFX Advanced
 
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
 
From Swing to JavaFX
From Swing to JavaFXFrom Swing to JavaFX
From Swing to JavaFX
 
Wicket Next (1.4/1.5)
Wicket Next (1.4/1.5)Wicket Next (1.4/1.5)
Wicket Next (1.4/1.5)
 
Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran Toch
 
Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008
Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008
Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008
 
The State of Wicket
The State of WicketThe State of Wicket
The State of Wicket
 
Testing Spring MVC and REST Web Applications
Testing Spring MVC and REST Web ApplicationsTesting Spring MVC and REST Web Applications
Testing Spring MVC and REST Web Applications
 
Apache Wicket Web Framework
Apache Wicket Web FrameworkApache Wicket Web Framework
Apache Wicket Web Framework
 
MVC Training Part 2
MVC Training Part 2MVC Training Part 2
MVC Training Part 2
 

Similar to ASP.NET MVC - Whats The Big Deal

CTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVCCTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVCBarry Gervin
 
Introduction To Mvc
Introduction To MvcIntroduction To Mvc
Introduction To MvcVolkan Uzun
 
ASP.net MVC CodeCamp Presentation
ASP.net MVC CodeCamp PresentationASP.net MVC CodeCamp Presentation
ASP.net MVC CodeCamp Presentationbuildmaster
 
Asp.Net Mvc
Asp.Net MvcAsp.Net Mvc
Asp.Net Mvcmicham
 
Hanselman lipton asp_connections_ams304_mvc
Hanselman lipton asp_connections_ams304_mvcHanselman lipton asp_connections_ams304_mvc
Hanselman lipton asp_connections_ams304_mvcdenemedeniz
 
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introductionTomi Juhola
 
Simple mvc4 prepared by gigin krishnan
Simple mvc4 prepared by gigin krishnanSimple mvc4 prepared by gigin krishnan
Simple mvc4 prepared by gigin krishnanGigin Krishnan
 
Asp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design PatternAsp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design Patternmaddinapudi
 
Developing ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller PatternDeveloping ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller Patterngoodfriday
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC PresentationVolkan Uzun
 
Technoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development servicesTechnoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development servicesAaron Jacobson
 
Difference between asp.net web forms and asp.net mvc
Difference between asp.net web forms and asp.net mvcDifference between asp.net web forms and asp.net mvc
Difference between asp.net web forms and asp.net mvcUmar Ali
 
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVC
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVCApplying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVC
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVCMohamed Meligy
 
AspMVC4 start101
AspMVC4 start101AspMVC4 start101
AspMVC4 start101Rich Helton
 
Controllers & actions
Controllers & actionsControllers & actions
Controllers & actionsEyal Vardi
 

Similar to ASP.NET MVC - Whats The Big Deal (20)

CTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVCCTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVC
 
Introduction To Mvc
Introduction To MvcIntroduction To Mvc
Introduction To Mvc
 
ASP.net MVC CodeCamp Presentation
ASP.net MVC CodeCamp PresentationASP.net MVC CodeCamp Presentation
ASP.net MVC CodeCamp Presentation
 
Asp.Net Mvc
Asp.Net MvcAsp.Net Mvc
Asp.Net Mvc
 
Hanselman lipton asp_connections_ams304_mvc
Hanselman lipton asp_connections_ams304_mvcHanselman lipton asp_connections_ams304_mvc
Hanselman lipton asp_connections_ams304_mvc
 
Mvc
MvcMvc
Mvc
 
Asp.net,mvc
Asp.net,mvcAsp.net,mvc
Asp.net,mvc
 
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introduction
 
Simple mvc4 prepared by gigin krishnan
Simple mvc4 prepared by gigin krishnanSimple mvc4 prepared by gigin krishnan
Simple mvc4 prepared by gigin krishnan
 
MVC 4
MVC 4MVC 4
MVC 4
 
Asp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design PatternAsp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design Pattern
 
Developing ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller PatternDeveloping ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller Pattern
 
ASP.NET MVC 3
ASP.NET MVC 3ASP.NET MVC 3
ASP.NET MVC 3
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
Technoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development servicesTechnoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development services
 
Difference between asp.net web forms and asp.net mvc
Difference between asp.net web forms and asp.net mvcDifference between asp.net web forms and asp.net mvc
Difference between asp.net web forms and asp.net mvc
 
MVC Framework
MVC FrameworkMVC Framework
MVC Framework
 
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVC
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVCApplying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVC
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVC
 
AspMVC4 start101
AspMVC4 start101AspMVC4 start101
AspMVC4 start101
 
Controllers & actions
Controllers & actionsControllers & actions
Controllers & actions
 

More from Venketash (Pat) Ramadass

More from Venketash (Pat) Ramadass (6)

emediaIT - Unified Communications - 2011.09.01
emediaIT - Unified Communications - 2011.09.01emediaIT - Unified Communications - 2011.09.01
emediaIT - Unified Communications - 2011.09.01
 
emediaIT - Mobility Solutions - 2011.03.01
emediaIT - Mobility Solutions - 2011.03.01emediaIT - Mobility Solutions - 2011.03.01
emediaIT - Mobility Solutions - 2011.03.01
 
emediaIT - Sharepoint 2010 and K2 Breakfast - 2010.04.22
emediaIT - Sharepoint 2010 and K2 Breakfast - 2010.04.22emediaIT - Sharepoint 2010 and K2 Breakfast - 2010.04.22
emediaIT - Sharepoint 2010 and K2 Breakfast - 2010.04.22
 
emediaIT and Dell Breakfast - 2009.11.05
emediaIT and Dell Breakfast - 2009.11.05emediaIT and Dell Breakfast - 2009.11.05
emediaIT and Dell Breakfast - 2009.11.05
 
Silverlight - What Is It And How Can We Use It
Silverlight - What Is It And How Can We Use ItSilverlight - What Is It And How Can We Use It
Silverlight - What Is It And How Can We Use It
 
C# 4.0 - Whats New
C# 4.0 - Whats NewC# 4.0 - Whats New
C# 4.0 - Whats New
 

Recently uploaded

Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 

Recently uploaded (20)

Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 

ASP.NET MVC - Whats The Big Deal

  • 1. Venketash (Pat) Ramadass Systems Architect & Managing Director emediaIT pat.ramadass@emediait.com http://patramadass.emediait.com
  • 2. Separation of Concerns  MVC  ASP.NET MVC  Demonstrations of building simple ASP.NET  MVC functionality Questions 
  • 3. Presentation logic, business logic and data  access logic are mixed together too often  Business logic code within the User Interface  Unmanagable code, goes against good OO principles Proper Separation of Concerns (SoC) solves  this by de-coupling the overall architecture
  • 4. Stands for Model-View-Controller  It is a design pattern for software development  Designed to promote and enforce Separation  of Concerns  Model – Data Access and Business Logic  View – User Interface  Controller – Handles User Interaction and Model Manipulation
  • 5. User User Interface Generates Events View(s) Controller(s) Provides Data Manipulates Model
  • 6. MVC Framework which Microsoft is adding to  ASP.NET Alternative to ASP.NET, not a replacement  Can combine both in a single solution  Currently in public beta, but there are  production systems using it already
  • 7. Clear separation of concerns (SoC)  Testability - support for TDD  Fine-grained control over HTML and  JavaScript Intuitive URLs (Routing) – SEO Friendly 
  • 8. Functionality Webforms ASP.NET MVC URLs Page names and URL Routing Programmatically - Rewriting REST Event Driven Yes No Stateful Yes (Viewstate) No Easily Unit Tested No Yes Abstraction from HTML Yes No Exact control over HTML No Yes Supports ORM Yes Yes Easy use of Third Party UI Yes Partial (No state/postback controls controls only) Works on Linux/Mono Yes (Partial) Not yet supported, but can be made to work The above is not intended to be a complete list, it simply highlights some key differences.
  • 9. 6 View Routing Controller 1 2 5 Rules 3 1. HTTP Request 2. ASP.NET MVC Framework evaluates URL against registered Routing Rules and forwards the request to a matching Controller Model Data Store 4 3. Controller calls Model to build ViewData, if required 4. The Model returns the requested Data to the Controller 5. The Controller selects a View and passes the Model to the View 6. View renders and returns HTTP Response
  • 10. Creating a new MVC Project  Folder Structure  Sample application included in ASP.NET MVC  Application Template A URL does not equal a page  Understanding URL Routing 
  • 11. URL: /Product/Details/3   This URL is parsed into three parts like this: ▪ Controller = ProductController ▪ Action = Details ▪ Id = 3  The request is therefore routed to the Details() action on the ProductController class, with a Id parameter of 3  Notice that the suffix Controller is tacked on to the end of the Controller parameter.
  • 12. Default Route   Default Controller: HomeController  Default Action: Index  Default Id: Empty String URL: /Employee   This URL is parsed into three parts like this: ▪ Controller = EmployeeController ▪ Action = Index ▪ Id = “”  The request is therefore routed to the Index() action on the EmployeeController class
  • 13. Default Route   Default Controller: HomeController  Default Action: Index  Default Id: Empty String URL: http://localhost, i.e. Without supplying a  further URL
  • 14. In a blog application, you may want to handle  incoming requests that look like: /Archive/12- 25-2009. For this you would need a Custom Route. The order in which routes are added is  important
  • 15.
  • 16. A controller should only contain the bare minimum of logic  required to return the right view or redirect the user to another action. A controller is just a Class, inherits from  System.Web.Mvc.Controller HomeController.cs has 2 methods called Index() and About(),  these are the actions it exposes. The URL /Home/Index invokes the HomeController.Index()  method and the URL /Home/About invokes the HomeController.About() method. Any public method in a controller is exposed as a controller  action.
  • 17. A method used as a controller action cannot be overloaded or static  A controller action returns action result.  Six standard types of action results:   ViewResult – Represents HTML and markup.  EmptyResult – Represents no result.  RedirectResult – Represents a redirection to a new URL.  RedirectToRouteResult – Represents a redirection to a new controller action.  JsonResult – Represents a JavaScript Object Notation result that can be used in an AJAX application.  ContentResult – Represents a text result. ContentResult is useful for returning plain text such as dates, integers etc 
  • 18. Instead of returning an action result directly, you  normally call one of the following methods on the Controller base class:  View – Returns a ViewResult action result.  Redirect – Returns a RedirectResult action result.  RedirectToAction – Returns a RedirectToRouteResult action result.  RedirectToRoute – Returns a RedirectToRouteResult action result.  Json – Returns a JsonResult action result.  Content – Returns a ContentResult action result.
  • 20. A view should contain only logic related to generating the user  interface. A view contains the HTML markup and content that is sent to the  browser. A view is the equivalent of a page. In general, to return a view for a controller action, you must create  a subfolder in the Views folder with the same name as your controller. Within the subfolder, you must create an .aspx file with the same name as the controller action. The HomeController.Index() action returns a view located at the  following path: ViewsHomeIndex.aspx The HomeController.About() action returns a view located at the  following path: ViewsHomeAbout.aspx
  • 21. Adding a new View Page  Using HTML Helpers to Generate View  Content Using View Data to Pass Data to a View 
  • 22. An MVC model contains all of your  application logic that is not contained in a view or a controller. This should be all of your business logic and data access logic Aim for fat models and skinny controllers 
  • 23. Create a new Database  Create a new Model  Using LINQ in Controller Actions  Using the Repository Pattern 
  • 24. Why TDD?  Testing the View returned by a Controller  Testing the View Data returned by a  Controller Testing the Action Result returned by a  Controller
  • 25. ASP.NET 3.5 Installed  Visual Studio 2008  Microsoft ASP.NET MVC Installed   Download the current Beta
  • 26. ASP.NET 3.5 Installed  Visual Studio 2008  Microsoft ASP.NET MVC Installed   Download the current Beta
  • 27. More Involved Examples   Add/Edit/Delete and use of Server Controls ▪ Email me if you would like information on this Custom HTML Helpers   You can create your own Helper Classes and Extension Methods which return formatted HTML strings Unity Dependency Injection / IoC Container   Framework for Dependency Injection and Controller Factories  Stand alone version and bundled with Enterprise Library 4.0
  • 28. Using Partials as Templates for formatting/rendering   For example a template for how a Movie is rendered  HTML.RenderPartial(string partialViewName, object Model) Action Filters   Attributes that can be applied to a Controller Action or entire Controller ▪ Authorization ▪ Action Result ▪ Exception ▪ Custom  For example for Logging/Tracing
  • 29. Upgrading existing code will take a long time, better  for Greenfields projects For now, applications which require richer user  interfaces will require more work with MVC  Third party UI library vendors have started developing and releasing updated controls Some SEO issues, may require URL rewrite engine,  but can be done Not officially supported on pre Windows Server  2003/IIS 6, but can work
  • 30. If you are developing a new system it is worth  evaluating the pros and cons, it is not a silver bullet however ASP.NET MVC is much more in line with what is  happening elsewhere in the industry, for example Ruby on Rails We feel that the Pros outweigh the Cons in  general and are implementing ASP.NET MVC in our new Web Applications wherever possible
  • 31. http://www.asp.net/mvc/   Official Site http://weblogs.asp.net/scottgu   Scott Guthrie http://www.hanselman.com/   Scott Hanselman http://quickstarts.asp.net/previews/mvc   Videos, Examples, Blogs http://martinfowler.com/articles/injection.html   Repository/Dependency Injection Pattern http://www.pnpguidance.net/Category/Unity.aspx   Unity http://patramadass.emediait.com   This presentation, example code