• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Deep Dive: MVC Controller Architecture
 

Deep Dive: MVC Controller Architecture

on

  • 1,571 views

The driving force behind the MVC architecture is the controller. It returns the appropriate view and model for a request, but that is not the end of the story. In ASP.NET MVC, the controller is much ...

The driving force behind the MVC architecture is the controller. It returns the appropriate view and model for a request, but that is not the end of the story. In ASP.NET MVC, the controller is much more powerful. I will go deep into the infrastructure of the controller. You will discover that there is much more to this powerful framework than is shown in typical examples, and you will be able to use this knowledge for business scenarios that go beyond serving simple web pages.

Statistics

Views

Total Views
1,571
Views on SlideShare
1,565
Embed Views
6

Actions

Likes
1
Downloads
24
Comments
0

2 Embeds 6

http://www.linkedin.com 5
https://www.linkedin.com 1

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • The title of this demo is actually funny to me. Controllers are already services. A request comes in, it is routed to the appropriate action on a controller, and a response is sent back out. Controllers are services that typically respond with information to be rendered in a browser.

Deep Dive: MVC Controller Architecture Deep Dive: MVC Controller Architecture Presentation Transcript

  • MVC Controller Architecture
    Deep Dive
  • Holistic Look
    Where do controllers fit?
  • Simple Application
    A web site
    Abstraction costs higher than return
    Does not integrate with business processes
    Solo project
  • Simple Application
    Controller is the life of this app!
  • Simple Application
    Controller
    View
    Model
  • Layered Application
    More thought placed in design
    Integrates into larger infrastructures
    Abstraction necessary for reuse
    Team project
  • Layered Application
    Controller is the public interface
  • Layered Application
    Presentation Layer
    Crosscutting Concerns
    Controller
    View
    ViewModel
    Business Layer
    Model
    Workflow
    Component
    Data Access Layer
    DAL Component
    Gateway
  • Enterprise Application
    Complexity determined by business needs
    But strive for simplicity
    And reusability
    Will integrate into larger infrastructure
  • Enterprise Application
    Controller is still the public interface
  • Enterprise Application
    BUT
  • Enterprise Application
    It may be the life of an app if small…
  • Enterprise Application
    This is reduced…
    Web App
    Public Service
    Console App
    WPF App
    Workflow Service
    Business Service
    Data Service
    DB
  • Enterprise Application
    It probably looks like this...
  • The Controller
    Designing the perfect cog
  • Question
    Should I use repositories?
  • Should I Use Repositories?
    Yes
  • Should I Use Repositories?
    Only composition logic
    Encapsulate and abstract other logic
  • Considerations
    Flexibility
    Maintainability
    Related entities
    Are you using more than one repository per controller?
  • DEMO
    Encapsulation is simple
  • Question
    Do I need one repository per model?
  • One Repository Per Model?
    No
  • One Repository Per Model?
    Probably
  • Repository Style
    Coarse-Grained
    IEventRepository
    Fine-Grained
    IEventRepository
    IAttendeeRepository
  • Question
    How do I transition to n-tier?
  • Transition to n-tier?
    Easier
  • Transition to n-tier?
    If you followed my previous recommendations
  • Breaking It Up
    Presentation Layer
    Crosscutting Concerns
    Controller
    View
    ViewModel
    Business Layer
    Model
    Workflow
    Component
    Data Access Layer
    DAL Component
    Gateway
  • DEMO
    Moving to a tier
    Without affecting your Controller!!!
  • The Controller
    Routing
    Verbs
    Action Results
    Standard Controllers
    Custom Controllers
  • Routing
    HTTP Request
    web.config
    Global.asax
    Favor Resources
  • Routing
    Physical
    Controllers
    Logical
    Routes
  • DEMO
    Routing
  • Verbs
    HTTP Methods
    AcceptVerbs Attribute
    RESTful CRUD
    GET
    PUT
    POST
    DELETE
  • Verbs
    HEAD
    OPTIONS
    CONNECT
    TRACE
    Custom Verbs
  • DEMO
    Verbs
  • Action Results
    Controllers do something when called
    Standard action results
    ViewResult
    JsonResult
    ContentResult
    EmptyResult
    FileResult
    HttpUnauthorizedResult
  • Action Results
    More Standard actions
    JavaScriptResult
    RedirectResult
    RedirectToRouteResult
    Make your own!
  • DEMO
    Custom Action Results
  • Standard Controllers
    Great for standard web applications
    Convention-based
    Even non-standard controllers are convention based when used with views
  • Custom Controllers
    Can decorate the standard class
    Can inherit from ControllerBase
    Can implement IController
    Use for non-standard applications
    or for more control
  • DEMO
    Custom Controllers
  • Controller as a Service
    MVC apps are typically web sites
    They can also be web services
    Do you have a mixed site/service?
    It can also be a pure service without JSON
  • DEMO
    Controller as a Service
  • Resources
    Software Application Developers
    http://msdn.microsoft.com/
    Infrastructure Professionals
    http://technet.microsoft.com/
    technetindia
    msdnindia
    @technetindia
    @msdnindia
  • © 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.
    The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.