SlideShare a Scribd company logo
ASP.Net MVC 3 - Basics
    Saravanan Subburayal

           07/02/2012




                           1
   Take away
   MVC Pattern
   ASP.Net MVC – Who Am I?
   ASP.Net MVC Goals
   ASP.Net Web forms vs MVC
   ASP.Net MVC - Execution process
   ASP.Net MVC Project structure
   Routing basics
   Controller
   View
   Model
   What’s Next?


                                      2
   Understanding MVC pattern
   Appreciate MVC in ASP.Net MVC
   Difference with Web forms
   Understanding of routing
   Understanding Model, View, Controller
   Understanding the request handling pipe line
    (execution process)




                                                   3
   Architectural pattern
   SoC (Separation of Concerns)
   1979 – Trygve Reenskaug, Smalltalk-80
    class library
   M(Model) – V (View) – C (Controller)




                                            4
• Domain Logic
                 • Data persistence



• Presentation
 (look & feel)
                        • Flow control




                                         5
   Spread everywhere
    ◦   Ruby – RoR, PureMVC
    ◦   .Net – Sprint.Net, MonoRail, ASP.Net MVC
    ◦   Java – Swing, Struts, Sprintg
    ◦   Python – Django, PureMVC
    ◦   Apple – Cocoa, Cocoa touch




                                                   6
   New way of developing ASP.Net web pages
   Light weight and highly testable
    presentation framework
   Built on top of ASP.Net engine

         ASP.Net Web Form     ASP.Net MVC


                 ASP.Net Core engine


                    .Net framework


                                              7
   SoC
   Pluggability
   Easily testable (TDD)
   Friendly URLs (www.abc.com/home/contact)
   Extending ASP.Net (retain existing features)
   Full control of HTML




                                                   8
ASP.Net Web forms                  ASP.Net MVC
Event driven                       Model driven

Used Page controller pattern       Uses Front controller pattern

Supports ASP.Net Server controls   Supports raw HTML/JS

Automatic state management         Manual state manaement
(Viewstate and Postback)
Faster development (RAD)           Distributed development

TDD is difficult                   TDD is easier

UI and logic tightly coupled       Loosely coupled, Pluggability

Complex URLs                       Rest based URLs



                                                                   9
Web
                                Response
   request

          Input

UrlRoutingModul
                                   View
        e

Selects


 RouteHandler                   View Engine

          Creates


  MvcHandler                      Result

Creates              Invokes
                                     Generates


   Controller                    Action

                    Operation




                                                 10
11
for Physical store data
 Scripts, CSS, Images…


                             Classes for controllers
Classes for domain logic



aspx, ascx, cshtml, mast   for script files(AJAX, Jquery)
           er


                                  Routing table


    Unit test cases




                                                            12
   Routes Browser requests to Controller actions
   Uses route table to handle incoming requests
   Route table is available in Global.asax
   Application_start() -> RegisterRoutes()     -
    >RouteTable




                                                    13
   Default route breaks requests into 3
    segments
    1. Controller
    2. Action
    3. Parameter



        http://localhost/Home/About/3

       http://localhost   Home         About     3
                          Controller   Action Parameter


                                                          14
   ? http://localhost/student
   ? http://localhost/




                                 15
   Controls the way user interacts with app
   Contains flow control logic
   Selects the view to render
   Sending Model and information for a
    particular view
   Making decisions for UI, redirection, security..
   It is a C# class
   Contains Actions(Methods)
   Eg., HomeController.cs


                                                       16
   Contains HTML markup and content
   Contains logic relevant to generating UI
   Equivalent of a Page (ASP.Net web form)
   View path should map to controller actions
    ◦ HomeController.Index() =>
      ViewHomeIndex.aspx
   Eg., Index.aspx, About.aspx




                                                 17
   It contains
    ◦   Model
    ◦   Business logic
    ◦   Validation logic
    ◦   Data access logic




                            18
19

More Related Content

What's hot (19)

276626961 java-j2 ee-course-curriculum-modular
276626961 java-j2 ee-course-curriculum-modular
sloumaallagui1
 
servlets and jsp
servlets and jsp
sachin kumbhojkar
 
Spring mvc
Spring mvc
Hui Xie
 
Zend framework 02 - mvc
Zend framework 02 - mvc
Tricode (part of Dept)
 
Struts
Struts
s4al_com
 
Sftplite
Sftplite
sivachandra mandalapu
 
Mock component in munit
Mock component in munit
sivachandra mandalapu
 
Jms selector
Jms selector
sivachandra mandalapu
 
Chap4 4 2
Chap4 4 2
Hemo Chella
 
How to use splitter component
How to use splitter component
RaviRajuRamaKrishna
 
Object store
Object store
sivachandra mandalapu
 
JBoss AS7 web services
JBoss AS7 web services
alepalin
 
Modern Java Web Development
Modern Java Web Development
zenyk
 
Mule flow complete
Mule flow complete
Son Nguyen
 
How to use smtp endpoint
How to use smtp endpoint
sivachandra mandalapu
 
Ch. 13 filters and wrappers
Ch. 13 filters and wrappers
Manolis Vavalis
 
RubyConf Bangladesh 2017 - Rails buggy code
RubyConf Bangladesh 2017 - Rails buggy code
Ruby Bangladesh
 
Basic example using for each component
Basic example using for each component
prudhvivreddy
 

Similar to Asp.Net MVC3 - Basics (20)

Asp.Net Mvc
Asp.Net Mvc
micham
 
Introduction to ASP.Net MVC
Introduction to ASP.Net MVC
Sagar Kamate
 
Asp.net difference faqs- 8
Asp.net difference faqs- 8
Umar Ali
 
ASP.NET MVC as the next step in web development
ASP.NET MVC as the next step in web development
Volodymyr Voytyshyn
 
Mvc3 crash
Mvc3 crash
Melick Baranasooriya
 
Hanselman lipton asp_connections_ams304_mvc
Hanselman lipton asp_connections_ams304_mvc
denemedeniz
 
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
Chalermpon Areepong
 
8-9-10. ASP_updated8-9-10. ASP_updated8-9-10. ASP_updated
8-9-10. ASP_updated8-9-10. ASP_updated8-9-10. ASP_updated
dioduong345
 
ASP .net MVC
ASP .net MVC
Divya Sharma
 
ASP.NET MVC - Whats The Big Deal
ASP.NET MVC - Whats The Big Deal
Venketash (Pat) Ramadass
 
MVC 4
MVC 4
Vasilios Kuznos
 
Day7
Day7
madamewoolf
 
Asp.Net Mvc Dev Days09
Asp.Net Mvc Dev Days09
Bruno Matos Tavares
 
Hands on with ASP.NET MVC
Hands on with ASP.NET MVC
rahulsahay19
 
Model View Controller-Introduction-Overview.pptx
Model View Controller-Introduction-Overview.pptx
MarioCaday2
 
Programming ASP NET MVC 4 Developing Real World Web Applications with ASP NET...
Programming ASP NET MVC 4 Developing Real World Web Applications with ASP NET...
barbuhalahdl
 
Introduction To Mvc
Introduction To Mvc
Volkan Uzun
 
Asp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design Pattern
maddinapudi
 
Mvc summary
Mvc summary
Muhammad Younis
 
MVC 6 Introduction
MVC 6 Introduction
Sudhakar Sharma
 
Asp.Net Mvc
Asp.Net Mvc
micham
 
Introduction to ASP.Net MVC
Introduction to ASP.Net MVC
Sagar Kamate
 
Asp.net difference faqs- 8
Asp.net difference faqs- 8
Umar Ali
 
ASP.NET MVC as the next step in web development
ASP.NET MVC as the next step in web development
Volodymyr Voytyshyn
 
Hanselman lipton asp_connections_ams304_mvc
Hanselman lipton asp_connections_ams304_mvc
denemedeniz
 
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
Chalermpon Areepong
 
8-9-10. ASP_updated8-9-10. ASP_updated8-9-10. ASP_updated
8-9-10. ASP_updated8-9-10. ASP_updated8-9-10. ASP_updated
dioduong345
 
Hands on with ASP.NET MVC
Hands on with ASP.NET MVC
rahulsahay19
 
Model View Controller-Introduction-Overview.pptx
Model View Controller-Introduction-Overview.pptx
MarioCaday2
 
Programming ASP NET MVC 4 Developing Real World Web Applications with ASP NET...
Programming ASP NET MVC 4 Developing Real World Web Applications with ASP NET...
barbuhalahdl
 
Introduction To Mvc
Introduction To Mvc
Volkan Uzun
 
Asp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design Pattern
maddinapudi
 
Ad

More from Saravanan Subburayal (6)

Devops as a service
Devops as a service
Saravanan Subburayal
 
Machine learning
Machine learning
Saravanan Subburayal
 
Welcome to big data
Welcome to big data
Saravanan Subburayal
 
Azure series 2 creating a cloud service - web role
Azure series 2 creating a cloud service - web role
Saravanan Subburayal
 
Fluent validation
Fluent validation
Saravanan Subburayal
 
Cloud - Azure – an introduction
Cloud - Azure – an introduction
Saravanan Subburayal
 
Ad

Asp.Net MVC3 - Basics

  • 1. ASP.Net MVC 3 - Basics Saravanan Subburayal 07/02/2012 1
  • 2. Take away  MVC Pattern  ASP.Net MVC – Who Am I?  ASP.Net MVC Goals  ASP.Net Web forms vs MVC  ASP.Net MVC - Execution process  ASP.Net MVC Project structure  Routing basics  Controller  View  Model  What’s Next? 2
  • 3. Understanding MVC pattern  Appreciate MVC in ASP.Net MVC  Difference with Web forms  Understanding of routing  Understanding Model, View, Controller  Understanding the request handling pipe line (execution process) 3
  • 4. Architectural pattern  SoC (Separation of Concerns)  1979 – Trygve Reenskaug, Smalltalk-80 class library  M(Model) – V (View) – C (Controller) 4
  • 5. • Domain Logic • Data persistence • Presentation (look & feel) • Flow control 5
  • 6. Spread everywhere ◦ Ruby – RoR, PureMVC ◦ .Net – Sprint.Net, MonoRail, ASP.Net MVC ◦ Java – Swing, Struts, Sprintg ◦ Python – Django, PureMVC ◦ Apple – Cocoa, Cocoa touch 6
  • 7. New way of developing ASP.Net web pages  Light weight and highly testable presentation framework  Built on top of ASP.Net engine ASP.Net Web Form ASP.Net MVC ASP.Net Core engine .Net framework 7
  • 8. SoC  Pluggability  Easily testable (TDD)  Friendly URLs (www.abc.com/home/contact)  Extending ASP.Net (retain existing features)  Full control of HTML 8
  • 9. ASP.Net Web forms ASP.Net MVC Event driven Model driven Used Page controller pattern Uses Front controller pattern Supports ASP.Net Server controls Supports raw HTML/JS Automatic state management Manual state manaement (Viewstate and Postback) Faster development (RAD) Distributed development TDD is difficult TDD is easier UI and logic tightly coupled Loosely coupled, Pluggability Complex URLs Rest based URLs 9
  • 10. Web Response request Input UrlRoutingModul View e Selects RouteHandler View Engine Creates MvcHandler Result Creates Invokes Generates Controller Action Operation 10
  • 11. 11
  • 12. for Physical store data Scripts, CSS, Images… Classes for controllers Classes for domain logic aspx, ascx, cshtml, mast for script files(AJAX, Jquery) er Routing table Unit test cases 12
  • 13. Routes Browser requests to Controller actions  Uses route table to handle incoming requests  Route table is available in Global.asax  Application_start() -> RegisterRoutes() - >RouteTable 13
  • 14. Default route breaks requests into 3 segments 1. Controller 2. Action 3. Parameter http://localhost/Home/About/3 http://localhost Home About 3 Controller Action Parameter 14
  • 15. ? http://localhost/student  ? http://localhost/ 15
  • 16. Controls the way user interacts with app  Contains flow control logic  Selects the view to render  Sending Model and information for a particular view  Making decisions for UI, redirection, security..  It is a C# class  Contains Actions(Methods)  Eg., HomeController.cs 16
  • 17. Contains HTML markup and content  Contains logic relevant to generating UI  Equivalent of a Page (ASP.Net web form)  View path should map to controller actions ◦ HomeController.Index() => ViewHomeIndex.aspx  Eg., Index.aspx, About.aspx 17
  • 18. It contains ◦ Model ◦ Business logic ◦ Validation logic ◦ Data access logic 18
  • 19. 19

Editor's Notes

  • #5: Django A complete Python web application framework. Django prefers to call its MVC implementation MTV, for model-template-view.
  • #7: Django A complete Python web application framework. Django prefers to call its MVC implementation MTV, for model-template-view.