KEMBAR78
Asp.Net MVC3 - Basics | PPTX
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

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.
  • 12.
    for Physical storedata 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.

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.