Download presentation
Presentation is loading. Please wait.
Published byGillian Goodman Modified over 9 years ago
1
MVC Controller Architecture Deep Dive
2
Holistic Look Where do controllers fit?
3
Simple Application A web site Abstraction costs higher than return Does not integrate with business processes Solo project
4
Simple Application Controller is the life of this app!
5
Simple Application Model View Controller
6
Layered Application More thought placed in design Integrates into larger infrastructures Abstraction necessary for reuse Team project
7
Layered Application Controller is the public interface
8
Layered Application Workflow Component Model Business Layer DAL Component Gateway Data Access Layer Controller View ViewModel Presentation Layer Crosscutting Concerns
9
Enterprise Application Complexity determined by business needs –But strive for simplicity And reusability Will integrate into larger infrastructure
10
Enterprise Application Controller is still the public interface
11
Enterprise Application BUT
12
Enterprise Application It may be the life of an app if small…
13
Enterprise Application DB Workflow Service Data Service Business Service WPF App Console App Web App This is reduced… Public Service
14
Enterprise Application It probably looks like this...
15
The Controller Designing the perfect cog
16
Question Should I use repositories?
17
Should I Use Repositories? Yes
18
Should I Use Repositories? Only composition logic Encapsulate and abstract other logic
19
DEMO Encapsulation is simple
20
Question Do I need one repository per model?
21
One Repository Per Model? No
22
One Repository Per Model? Probably
23
Repository Style Coarse-Grained Fine-Grained IEventRepository IAttendeeRepository
24
Question How do I transition to n-tier?
25
Transition to n-tier? Easier
26
Transition to n-tier? If you followed my previous recommendations
27
Breaking It Up Workflow Component Model Business Layer DAL Component Gateway Data Access Layer Controller View ViewModel Presentation Layer Crosscutting Concerns
28
DEMO Moving to a tier Without affecting your Controller!!!
29
Considerations Flexibility Maintainability Related entities Are you using more than one repository per controller?
30
The Controller Routing Verbs Action Results Standard Controllers Custom Controllers
31
Routing HTTP Request web.config Global.asax Favor Resources
32
Routing Logical Physical Controllers Routes
33
DEMO Routing
34
Verbs HTTP Methods AcceptVerbs Attribute RESTful CRUD –GET –PUT –POST –DELETE
35
Verbs HEAD OPTIONS CONNECT TRACE Custom Verbs
36
DEMO Verbs
37
Action Results Controllers do something when called Standard action results –ViewResult –JsonResult –ContentResult –EmptyResult –FileResult –HttpUnauthorizedResult
38
Action Results More Standard actions –JavaScriptResult –RedirectResult –RedirectToRouteResult Make your own!
39
DEMO Custom Action Results
40
Standard Controllers Great for standard web applications Convention-based –Even non-standard controllers are convention based when used with views
41
Custom Controllers Can decorate the standard class Can inherit from ControllerBase Can implement IController Use for non-standard applications –or for more control
42
DEMO Custom Controllers
43
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
44
DEMO Controller as a Service
45
Resources Software Application Developers http://msdn.microsoft.com/ Infrastructure Professionals http://technet.microsoft.com/ msdnindia technetindia @msdnindia @technetindia
46
© 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.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.