Mais conteúdo relacionado Semelhante a Working with Controllers and Actions in MVC (20) Mais de LearnNowOnline (20) Working with Controllers and Actions in MVC1. Working with
Controllers and Actions
in MVC
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
2. Objectives
• Learn how controllers manage MVC applications
• Understand action methods and how they can
receive input
• Explore how you can return a result from an
action method
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
3. Agenda
• Introduction to Controllers
• Using a Controller to Manage the Application
• Controller Actions
• Returning Action Results
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
5. Introduction to Controllers
• Controller is the traffic cop to keep things smooth
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
6. Introduction to Controllers
• Controller is the traffic cop to keep things smooth
Responds to user input
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
7. Introduction to Controllers
• Controller is the traffic cop to keep things smooth
Responds to user input
Manages overall flow of application
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
8. Introduction to Controllers
• Controller is the traffic cop to keep things smooth
Responds to user input
Manages overall flow of application
Interacts with model to change state and data
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
9. Introduction to Controllers
• Controller is the traffic cop to keep things smooth
Responds to user input
Manages overall flow of application
Interacts with model to change state and data
Selects a result to respond to user
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
10. Introduction to Controllers
• Controller is the traffic cop to keep things smooth
Responds to user input
Manages overall flow of application
Interacts with model to change state and data
Selects a result to respond to user
• Does not itself contain UI, data, or business logic
code
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
11. Introduction to Controllers
• Controller is the traffic cop to keep things smooth
Responds to user input
Manages overall flow of application
Interacts with model to change state and data
Selects a result to respond to user
• Does not itself contain UI, data, or business logic
code
• Ultimately responsible for servicing requests
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
12. Introduction to Controllers
• Controller is the traffic cop to keep things smooth
Responds to user input
Manages overall flow of application
Interacts with model to change state and data
Selects a result to respond to user
• Does not itself contain UI, data, or business logic
code
• Ultimately responsible for servicing requests
The application’s logic
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
13. Introduction to Controllers
• Controller is the traffic cop to keep things smooth
Responds to user input
Manages overall flow of application
Interacts with model to change state and data
Selects a result to respond to user
• Does not itself contain UI, data, or business logic
code
• Ultimately responsible for servicing requests
The application’s logic
• Lots of attention in MVC 3
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
14. Using a Controller to Manage the
Application
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
15. Using a Controller to Manage the
Application
• Powerful but easy to use
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
16. Using a Controller to Manage the
Application
• Powerful but easy to use
• Implemented as .NET class with properties and
methods
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
17. Using a Controller to Manage the
Application
• Powerful but easy to use
• Implemented as .NET class with properties and
methods
• System.Web.Mvc namespace
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
18. Using a Controller to Manage the
Application
• Powerful but easy to use
• Implemented as .NET class with properties and
methods
• System.Web.Mvc namespace
Your controllers are likely to need very little code
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
19. Using a Controller to Manage the
Application
• Powerful but easy to use
• Implemented as .NET class with properties and
methods
• System.Web.Mvc namespace
Your controllers are likely to need very little code
Routine infrastructure encapsulated in base classes
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
22. Controllers in System.Web.Mvc
• Controller must:
Implement IController interface
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
23. Controllers in System.Web.Mvc
• Controller must:
Implement IController interface
Have a name ending in “Controller”
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
24. Controllers in System.Web.Mvc
• Controller must:
Implement IController interface
Have a name ending in “Controller”
Marked public, not abstract, no generic parameters
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
25. Controllers in System.Web.Mvc
• Controller must:
Implement IController interface
Have a name ending in “Controller”
Marked public, not abstract, no generic parameters
• Otherwise, not recognized as controller
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
26. Controllers in System.Web.Mvc
• Controller must:
Implement IController interface
Have a name ending in “Controller”
Marked public, not abstract, no generic parameters
• Otherwise, not recognized as controller
Methods never called as action methods
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
27. Controllers in System.Web.Mvc
• Controller must:
Implement IController interface
Have a name ending in “Controller”
Marked public, not abstract, no generic parameters
• Otherwise, not recognized as controller
Methods never called as action methods
• Normally inherit from Controller class
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
28. Controllers in System.Web.Mvc
• Controller must:
Implement IController interface
Have a name ending in “Controller”
Marked public, not abstract, no generic parameters
• Otherwise, not recognized as controller
Methods never called as action methods
• Normally inherit from Controller class
Which inherits from ControllerBase
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
29. Controllers in System.Web.Mvc
• Controller must:
Implement IController interface
Have a name ending in “Controller”
Marked public, not abstract, no generic parameters
• Otherwise, not recognized as controller
Methods never called as action methods
• Normally inherit from Controller class
Which inherits from ControllerBase
Which implements IController
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
30. The IController Interface
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
31. The IController Interface
• IController requirement isn’t onerous
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
32. The IController Interface
• IController requirement isn’t onerous
• Single purpose: find a controller and call Execute
method
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
33. The IController Interface
• IController requirement isn’t onerous
• Single purpose: find a controller and call Execute
method
• Simple interface definition:
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
34. The IController Interface
• IController requirement isn’t onerous
• Single purpose: find a controller and call Execute
method
• Simple interface definition:
public interface IController {
void Execute(RequestContext requestContext);
}
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
35. The IController Interface
• IController requirement isn’t onerous
• Single purpose: find a controller and call Execute
method
• Simple interface definition:
public interface IController {
void Execute(RequestContext requestContext);
}
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
36. The IController Interface
• IController requirement isn’t onerous
• Single purpose: find a controller and call Execute
method
• Simple interface definition:
public interface IController {
void Execute(RequestContext requestContext);
}
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
37. The IController Interface
• IController requirement isn’t onerous
• Single purpose: find a controller and call Execute
method
• Simple interface definition:
public interface IController {
void Execute(RequestContext requestContext);
}
• When request arrives
Routing identifies controller, calls Execute
Passes in object with context information
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
38. The ControllerBase Abstract Base
Class
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
39. The ControllerBase Abstract Base
Class
• Implements IController
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
40. The ControllerBase Abstract Base
Class
• Implements IController
Adds controller features, such as TempData and
ViewData
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
41. The ControllerBase Abstract Base
Class
• Implements IController
Adds controller features, such as TempData and
ViewData
Execute method creates ControllerContext object
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
42. The ControllerBase Abstract Base
Class
• Implements IController
Adds controller features, such as TempData and
ViewData
Execute method creates ControllerContext object
• Still pretty lightweight
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
43. The ControllerBase Abstract Base
Class
• Implements IController
Adds controller features, such as TempData and
ViewData
Execute method creates ControllerContext object
• Still pretty lightweight
Relatively little added functionality
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
44. The ControllerBase Abstract Base
Class
• Implements IController
Adds controller features, such as TempData and
ViewData
Execute method creates ControllerContext object
• Still pretty lightweight
Relatively little added functionality
Could build Web site with either IController or
ControllerBase
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
45. The Controller Class
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
46. The Controller Class
• Rich implementation of controller infrastructure
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
47. The Controller Class
• Rich implementation of controller infrastructure
• Inherits from ControllerBase
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
48. The Controller Class
• Rich implementation of controller infrastructure
• Inherits from ControllerBase
So indirectly implements IController
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
49. The Controller Class
• Rich implementation of controller infrastructure
• Inherits from ControllerBase
So indirectly implements IController
• Added features include
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
50. The Controller Class
• Rich implementation of controller infrastructure
• Inherits from ControllerBase
So indirectly implements IController
• Added features include
Action methods
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
51. The Controller Class
• Rich implementation of controller infrastructure
• Inherits from ControllerBase
So indirectly implements IController
• Added features include
Action methods
Action results
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
52. The Controller Class
• Rich implementation of controller infrastructure
• Inherits from ControllerBase
So indirectly implements IController
• Added features include
Action methods
Action results
Filters
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
53. The Controller Class
• Rich implementation of controller infrastructure
• Inherits from ControllerBase
So indirectly implements IController
• Added features include
Action methods
Action results
Filters
• Normally should implement your controllers
using Controller
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
54. The MVC Request Processing
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
55. The MVC Request Processing
• Response process to every user request
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
56. The MVC Request Processing
• Response process to every user request
IIS, ASP.NET, MVC collaboration
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
57. The MVC Request Processing
• Response process to every user request
IIS, ASP.NET, MVC collaboration
Request
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
58. The MVC Request Processing
• Response process to every user request
IIS, ASP.NET, MVC collaboration
Request
HTTP
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
59. The MVC Request Processing
• Response process to every user request
IIS, ASP.NET, MVC collaboration
Request
HTTP
Routing Engine Controller Factory Controller
View Action Method Action Invoker
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
60. The MVC Request Processing
• Response process to every user request
IIS, ASP.NET, MVC collaboration
Request
HTTP
Routing Engine Controller Factory Controller
View Action Method Action Invoker
HTTP
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
61. The MVC Request Processing
• Response process to every user request
IIS, ASP.NET, MVC collaboration
Request
HTTP
Routing Engine Controller Factory Controller
View Action Method Action Invoker
Response
HTTP
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
62. Action Method Selection
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
63. Action Method Selection
• Job of the action invoker
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
64. Action Method Selection
• Job of the action invoker
• More complicated than initially appears
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
65. Action Method Selection
• Job of the action invoker
• More complicated than initially appears
Multiple overloaded methods with same name
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
66. Action Method Selection
• Job of the action invoker
• More complicated than initially appears
Multiple overloaded methods with same name
Decorated with attributes that control use
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
67. Action Method Selection
• Job of the action invoker
• More complicated than initially appears
Multiple overloaded methods with same name
Decorated with attributes that control use
Action name may be different from method name
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
68. Action Method Selection
• Job of the action invoker
• More complicated than initially appears
Multiple overloaded methods with same name
Decorated with attributes that control use
Action name may be different from method name
• Starts by getting action portion of route
{controller}/{action}/{id}
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
69. Action Method Selection
• Job of the action invoker
• More complicated than initially appears
Multiple overloaded methods with same name
Decorated with attributes that control use
Action name may be different from method name
• Starts by getting action portion of route
{controller}/{action}/{id}
Default action is “Index”
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
70. Action Method Selection
• Job of the action invoker
• More complicated than initially appears
Multiple overloaded methods with same name
Decorated with attributes that control use
Action name may be different from method name
• Starts by getting action portion of route
{controller}/{action}/{id}
Default action is “Index”
• Then map action name to controller method
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
71. Action Method Selection
• Job of the action invoker
• More complicated than initially appears
Multiple overloaded methods with same name
Decorated with attributes that control use
Action name may be different from method name
• Starts by getting action portion of route
{controller}/{action}/{id}
Default action is “Index”
• Then map action name to controller method
Simplest: one method with that action name
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
73. Action Method Qualifications
• Method must meet requirements to be action
method:
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
74. Action Method Qualifications
• Method must meet requirements to be action
method:
Public and not static or Shared
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
75. Action Method Qualifications
• Method must meet requirements to be action
method:
Public and not static or Shared
Cannot be defined on System.Object or Controller
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
76. Action Method Qualifications
• Method must meet requirements to be action
method:
Public and not static or Shared
Cannot be defined on System.Object or Controller
o i.e., ToString() could not be an action method
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
77. Action Method Qualifications
• Method must meet requirements to be action
method:
Public and not static or Shared
Cannot be defined on System.Object or Controller
o i.e., ToString() could not be an action method
Cannot be a special method
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
78. Action Method Qualifications
• Method must meet requirements to be action
method:
Public and not static or Shared
Cannot be defined on System.Object or Controller
o i.e., ToString() could not be an action method
Cannot be a special method
Cannot have a NonAction attribute
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
79. Action Method Qualifications
• Method must meet requirements to be action
method:
Public and not static or Shared
Cannot be defined on System.Object or Controller
o i.e., ToString() could not be an action method
Cannot be a special method
Cannot have a NonAction attribute
• Action invoker uses reflection to find candidates
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
80. Action Method Qualifications
• Method must meet requirements to be action
method:
Public and not static or Shared
Cannot be defined on System.Object or Controller
o i.e., ToString() could not be an action method
Cannot be a special method
Cannot have a NonAction attribute
• Action invoker uses reflection to find candidates
All methods with same action name
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
81. Action Method Qualifications
• Method must meet requirements to be action
method:
Public and not static or Shared
Cannot be defined on System.Object or Controller
o i.e., ToString() could not be an action method
Cannot be a special method
Cannot have a NonAction attribute
• Action invoker uses reflection to find candidates
All methods with same action name
But method attributes can make this murky with
multiple candidates
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
82. ActionName Attribute
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
83. ActionName Attribute
• Normal convention is for controller method name
to be same as action name
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
84. ActionName Attribute
• Normal convention is for controller method name
to be same as action name
• Can give it a different action name
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
85. ActionName Attribute
• Normal convention is for controller method name
to be same as action name
• Can give it a different action name
Action name that is not a legal language name
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
86. ActionName Attribute
• Normal convention is for controller method name
to be same as action name
• Can give it a different action name
Action name that is not a legal language name
Use an MVC component name as action name
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
87. ActionName Attribute
• Normal convention is for controller method name
to be same as action name
• Can give it a different action name
Action name that is not a legal language name
Use an MVC component name as action name
Different naming standards
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
89. ActionMethodSelector Attribute
• Now action invoker has list of all matching action
names
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
90. ActionMethodSelector Attribute
• Now action invoker has list of all matching action
names
• Next examines ActionMethodSelector attributes
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
91. ActionMethodSelector Attribute
• Now action invoker has list of all matching action
names
• Next examines ActionMethodSelector attributes
Control what conditions a method should be used for a
request
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
92. ActionMethodSelector Attribute
• Now action invoker has list of all matching action
names
• Next examines ActionMethodSelector attributes
Control what conditions a method should be used for a
request
Single method: IsValidForRequest
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
93. ActionMethodSelector Attribute
• Now action invoker has list of all matching action
names
• Next examines ActionMethodSelector attributes
Control what conditions a method should be used for a
request
Single method: IsValidForRequest
o Executes on each candidate action method
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
94. ActionMethodSelector Attribute
• Now action invoker has list of all matching action
names
• Next examines ActionMethodSelector attributes
Control what conditions a method should be used for a
request
Single method: IsValidForRequest
o Executes on each candidate action method
o Return false, removed from list
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
95. ActionMethodSelector Attribute
• Now action invoker has list of all matching action
names
• Next examines ActionMethodSelector attributes
Control what conditions a method should be used for a
request
Single method: IsValidForRequest
o Executes on each candidate action method
o Return false, removed from list
• Implementations
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
96. ActionMethodSelector Attribute
• Now action invoker has list of all matching action
names
• Next examines ActionMethodSelector attributes
Control what conditions a method should be used for a
request
Single method: IsValidForRequest
o Executes on each candidate action method
o Return false, removed from list
• Implementations
NonAction attribute
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
97. ActionMethodSelector Attribute
• Now action invoker has list of all matching action
names
• Next examines ActionMethodSelector attributes
Control what conditions a method should be used for a
request
Single method: IsValidForRequest
o Executes on each candidate action method
o Return false, removed from list
• Implementations
NonAction attribute
AcceptVerbs attribute
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
98. ActionMethodSelector Attribute
• Now action invoker has list of all matching action
names
• Next examines ActionMethodSelector attributes
Control what conditions a method should be used for a
request
Single method: IsValidForRequest
o Executes on each candidate action method
o Return false, removed from list
• Implementations
NonAction attribute
AcceptVerbs attribute
HttpDelete, HttpGet, HttpPost, HttpPut
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
99. Controller Actions
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
100. Controller Actions
• Once invoked, action method does its job
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
101. Controller Actions
• Once invoked, action method does its job
Receive and process input
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
102. Controller Actions
• Once invoked, action method does its job
Receive and process input
Perform processing
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
103. Controller Actions
• Once invoked, action method does its job
Receive and process input
Perform processing
Generate output
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
104. Controller Actions
• Once invoked, action method does its job
Receive and process input
Perform processing
Generate output
o Select a view
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
105. Controller Actions
• Once invoked, action method does its job
Receive and process input
Perform processing
Generate output
o Select a view
o Write output directly to page
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
106. Controller Actions
• Once invoked, action method does its job
Receive and process input
Perform processing
Generate output
o Select a view
o Write output directly to page
o Raw data to browser
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
107. Controller Actions
• Once invoked, action method does its job
Receive and process input
Perform processing
Generate output
o Select a view
o Write output directly to page
o Raw data to browser
o Do nothing
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
108. Action Method Input
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
109. Action Method Input
• Most methods need data to do work
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
110. Action Method Input
• Most methods need data to do work
• Can come from a variety of sources
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
111. Action Method Input
• Most methods need data to do work
• Can come from a variety of sources
Environment
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
112. Action Method Input
• Most methods need data to do work
• Can come from a variety of sources
Environment
Operating system
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
113. Action Method Input
• Most methods need data to do work
• Can come from a variety of sources
Environment
Operating system
Nature of user request
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
114. Action Method Input
• Most methods need data to do work
• Can come from a variety of sources
Environment
Operating system
Nature of user request
Direct parameters
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
115. Action Method Input
• Most methods need data to do work
• Can come from a variety of sources
Environment
Operating system
Nature of user request
Direct parameters
Many others
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
116. Action Method Input
• Most methods need data to do work
• Can come from a variety of sources
Environment
Operating system
Nature of user request
Direct parameters
Many others
• Three broad sources for action method
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
117. Action Method Input
• Most methods need data to do work
• Can come from a variety of sources
Environment
Operating system
Nature of user request
Direct parameters
Many others
• Three broad sources for action method
Context objects
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
118. Action Method Input
• Most methods need data to do work
• Can come from a variety of sources
Environment
Operating system
Nature of user request
Direct parameters
Many others
• Three broad sources for action method
Context objects
Method parameters
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
119. Action Method Input
• Most methods need data to do work
• Can come from a variety of sources
Environment
Operating system
Nature of user request
Direct parameters
Many others
• Three broad sources for action method
Context objects
Method parameters
Model bindings
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
120. Context Object Input
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
121. Context Object Input
• Web requests come loaded with information
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
122. Context Object Input
• Web requests come loaded with information
HTTP headers
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
123. Context Object Input
• Web requests come loaded with information
HTTP headers
User information
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
124. Context Object Input
• Web requests come loaded with information
HTTP headers
User information
Browser and capability information
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
125. Context Object Input
• Web requests come loaded with information
HTTP headers
User information
Browser and capability information
User’s IP address
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
126. Context Object Input
• Web requests come loaded with information
HTTP headers
User information
Browser and capability information
User’s IP address
Authentication information
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
127. Context Object Input
• Web requests come loaded with information
HTTP headers
User information
Browser and capability information
User’s IP address
Authentication information
• Information available through context objects
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
128. Parameter Input
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
129. Parameter Input
• Specialized input customized for method
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
130. Parameter Input
• Specialized input customized for method
• MVC takes care of populating values
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
131. Parameter Input
• Specialized input customized for method
• MVC takes care of populating values
• Action invoker examines context objects for
parameter values and uses model binder
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
132. Parameter Input
• Specialized input customized for method
• MVC takes care of populating values
• Action invoker examines context objects for
parameter values and uses model binder
1. Request.Form
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
133. Parameter Input
• Specialized input customized for method
• MVC takes care of populating values
• Action invoker examines context objects for
parameter values and uses model binder
1. Request.Form
2. RouteData.Values
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
134. Parameter Input
• Specialized input customized for method
• MVC takes care of populating values
• Action invoker examines context objects for
parameter values and uses model binder
1. Request.Form
2. RouteData.Values
3. Request.QueryString
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
135. Parameter Input
• Specialized input customized for method
• MVC takes care of populating values
• Action invoker examines context objects for
parameter values and uses model binder
1. Request.Form
2. RouteData.Values
3. Request.QueryString
• Matches solely by name in order
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
136. Parameter Input
• Specialized input customized for method
• MVC takes care of populating values
• Action invoker examines context objects for
parameter values and uses model binder
1. Request.Form
2. RouteData.Values
3. Request.QueryString
• Matches solely by name in order
Once it finds a match it stops searching
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
137. Parameter Input
• Specialized input customized for method
• MVC takes care of populating values
• Action invoker examines context objects for
parameter values and uses model binder
1. Request.Form
2. RouteData.Values
3. Request.QueryString
• Matches solely by name in order
Once it finds a match it stops searching
Have to coordinate names to avoid duplicate names
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
138. Model Bindings
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
139. Model Bindings
• Model encapsulates data and business rules
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
140. Model Bindings
• Model encapsulates data and business rules
Use directly in controllers and views
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
141. Model Bindings
• Model encapsulates data and business rules
Use directly in controllers and views
Built-in features to make easy
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
142. Model Bindings
• Model encapsulates data and business rules
Use directly in controllers and views
Built-in features to make easy
Automatic data scaffolding
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
143. Controller Session State
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
144. Controller Session State
• SessionState attribute
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
145. Controller Session State
• SessionState attribute
Control how and whether controller uses session state
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
146. Controller Session State
• SessionState attribute
Control how and whether controller uses session state
MVC uses session state by default, if available
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
147. Controller Session State
• SessionState attribute
Control how and whether controller uses session state
MVC uses session state by default, if available
• SessionStateBehavior enumeration
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
148. Controller Session State
• SessionState attribute
Control how and whether controller uses session state
MVC uses session state by default, if available
• SessionStateBehavior enumeration
Default
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
149. Controller Session State
• SessionState attribute
Control how and whether controller uses session state
MVC uses session state by default, if available
• SessionStateBehavior enumeration
Default
Disabled
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
150. Controller Session State
• SessionState attribute
Control how and whether controller uses session state
MVC uses session state by default, if available
• SessionStateBehavior enumeration
Default
Disabled
ReadOnly
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
151. Controller Session State
• SessionState attribute
Control how and whether controller uses session state
MVC uses session state by default, if available
• SessionStateBehavior enumeration
Default
Disabled
ReadOnly
Required
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
152. Returning Action Results
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
153. Returning Action Results
• Action method follows a normal process
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
154. Returning Action Results
• Action method follows a normal process
Receives request and data
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
155. Returning Action Results
• Action method follows a normal process
Receives request and data
Process the request
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
156. Returning Action Results
• Action method follows a normal process
Receives request and data
Process the request
Generates response
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
157. Returning Action Results
• Action method follows a normal process
Receives request and data
Process the request
Generates response
• Many possible responses
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
158. Returning Action Results
• Action method follows a normal process
Receives request and data
Process the request
Generates response
• Many possible responses
• Three broad types of results
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
159. Returning Action Results
• Action method follows a normal process
Receives request and data
Process the request
Generates response
• Many possible responses
• Three broad types of results
HTML
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
160. Returning Action Results
• Action method follows a normal process
Receives request and data
Process the request
Generates response
• Many possible responses
• Three broad types of results
HTML
Redirect somewhere else
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
161. Returning Action Results
• Action method follows a normal process
Receives request and data
Process the request
Generates response
• Many possible responses
• Three broad types of results
HTML
Redirect somewhere else
Page data
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
162. Returning Action Results
• Action method follows a normal process
Receives request and data
Process the request
Generates response
• Many possible responses
• Three broad types of results
HTML
Redirect somewhere else
Page data
• All options based on ActionResult
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
163. Action Result
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
164. Action Result
• ActionResult base class
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
165. Action Result
• ActionResult base class
public abstract class ActionResult {
public abstract void ExecuteResult(ControllerContext context);
}
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
166. Action Result
• ActionResult base class
public abstract class ActionResult {
public abstract void ExecuteResult(ControllerContext context);
}
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
167. Action Result
• ActionResult base class
public abstract class ActionResult {
public abstract void ExecuteResult(ControllerContext context);
}
• ExecuteResult receives context information
• Takes care of low-level work of generating a
response
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
168. ActionResult Types
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
169. ActionResult Types
Type Helper Method Description
ContentResult Content() Raw text data
EmptyResult -- Returns nothing
FileResult File() Base class to send file
HttpNotFoundResult HttpNotFound() Returns HTTP 404
HttpStatusCodeResult -- Returns any HTTP status
HttpUnauthorizedResult -- Returns HTTP 401
JavaScriptResult JavaScript() Returns and executes script
JsonResult Json() JavaScript Object Notation
PartialViewResult PartialView() HTML snippet
RedirectResult Redirect() Redirect to URL
RedirectToRouteResult RedirectToRoute() Redirect to MVC route or action
ViewResult RedirectToAction()
View() Full HTML page
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
170. Passing Data to the View
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
171. Passing Data to the View
• Use either ViewData or ViewBag
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
172. Passing Data to the View
• Use either ViewData or ViewBag
Different faces of the same feature
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
173. Passing Data to the View
• Use either ViewData or ViewBag
Different faces of the same feature
A bit like ASP.NET Session object
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
174. Passing Data to the View
• Use either ViewData or ViewBag
Different faces of the same feature
A bit like ASP.NET Session object
Exposes ViewDataDictionary
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
175. Passing Data to the View
• Use either ViewData or ViewBag
Different faces of the same feature
A bit like ASP.NET Session object
Exposes ViewDataDictionary
But ViewData/ViewBag disappear after view rendered
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
176. Passing Data to the View
• Use either ViewData or ViewBag
Different faces of the same feature
A bit like ASP.NET Session object
Exposes ViewDataDictionary
But ViewData/ViewBag disappear after view rendered
Session lasts for the user session
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
177. Passing Data to the View
• Use either ViewData or ViewBag
Different faces of the same feature
A bit like ASP.NET Session object
Exposes ViewDataDictionary
But ViewData/ViewBag disappear after view rendered
Session lasts for the user session
• ViewData is loosely typed
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
178. Passing Data to the View
• Use either ViewData or ViewBag
Different faces of the same feature
A bit like ASP.NET Session object
Exposes ViewDataDictionary
But ViewData/ViewBag disappear after view rendered
Session lasts for the user session
• ViewData is loosely typed
• ViewBag is strongly typed
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
179. Passing Data to the View
• Use either ViewData or ViewBag
Different faces of the same feature
A bit like ASP.NET Session object
Exposes ViewDataDictionary
But ViewData/ViewBag disappear after view rendered
Session lasts for the user session
• ViewData is loosely typed
• ViewBag is strongly typed
Uses dynamic language feature of C# and VB
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
180. ViewData and ViewBag
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
181. ViewData and ViewBag
• Not limited to passing strings
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
182. ViewData and ViewBag
• Not limited to passing strings
• Keep in mind that they are same feature, but
different
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
183. ViewData and ViewBag
• Not limited to passing strings
• Keep in mind that they are same feature, but
different
Can mix and match in one action method/view
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
184. ViewData and ViewBag
• Not limited to passing strings
• Keep in mind that they are same feature, but
different
Can mix and match in one action method/view
Get the same result either way
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
185. ViewData and ViewBag
• Not limited to passing strings
• Keep in mind that they are same feature, but
different
Can mix and match in one action method/view
Get the same result either way
Generally should use ViewBag
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
186. ViewData and ViewBag
• Not limited to passing strings
• Keep in mind that they are same feature, but
different
Can mix and match in one action method/view
Get the same result either way
Generally should use ViewBag
• But in VB, using in controller requires setting
Option Strict Off
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
187. Returning Text Data: ContentResult
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
188. Returning Text Data: ContentResult
• HTML is dominant data format
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
189. Returning Text Data: ContentResult
• HTML is dominant data format
But browsers can deal with variety of formats
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
190. Returning Text Data: ContentResult
• HTML is dominant data format
But browsers can deal with variety of formats
• Use a ContentResult for other formats
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
191. Returning Text Data: ContentResult
• HTML is dominant data format
But browsers can deal with variety of formats
• Use a ContentResult for other formats
Content helper method
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
192. Returning Text Data: ContentResult
• HTML is dominant data format
But browsers can deal with variety of formats
• Use a ContentResult for other formats
Content helper method
Specify content as string
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
193. Returning Text Data: ContentResult
• HTML is dominant data format
But browsers can deal with variety of formats
• Use a ContentResult for other formats
Content helper method
Specify content as string
Optionally specify type, such as text/xml
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
194. Implicit Action Results
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
195. Implicit Action Results
• Return text and don’t need to specify type
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
196. Implicit Action Results
• Return text and don’t need to specify type
• If type is not string, calls ToString method with
InvariantCulture setting
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
197. Implicit Action Results
• Return text and don’t need to specify type
• If type is not string, calls ToString method with
InvariantCulture setting
Wraps in ContentResult object
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
198. Missing Resource:
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
199. Missing Resource:
• Useful to indicate that requested resource is not
available
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
200. Missing Resource:
• Useful to indicate that requested resource is not
available
User hacks a URL
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
201. Missing Resource:
• Useful to indicate that requested resource is not
available
User hacks a URL
• Returns HTTP 404 status code
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
202. Missing Resource:
• Useful to indicate that requested resource is not
available
User hacks a URL
• Returns HTTP 404 status code
Can mask an exception that an attacker could
otherwise use
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
203. Return any HTTP Status Code:
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
204. Return any HTTP Status Code:
• More flexible than HttpNotFoundResult
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
205. Return any HTTP Status Code:
• More flexible than HttpNotFoundResult
• Can specify any HTTP status code
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
206. Return any HTTP Status Code:
• More flexible than HttpNotFoundResult
• Can specify any HTTP status code
Optional description
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
207. Redirection Methods
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
208. Redirection Methods
• Methods on the Controller class
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
209. Redirection Methods
• Methods on the Controller class
• Return instances of redirection action methods
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
210. Redirection Methods
• Methods on the Controller class
• Return instances of redirection action methods
Permanent property set to true
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
211. Redirection Methods
• Methods on the Controller class
• Return instances of redirection action methods
Permanent property set to true
• Types
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
212. Redirection Methods
• Methods on the Controller class
• Return instances of redirection action methods
Permanent property set to true
• Types
RedirectPermanent method
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
213. Redirection Methods
• Methods on the Controller class
• Return instances of redirection action methods
Permanent property set to true
• Types
RedirectPermanent method
RedirectToRoutePermanent method
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
214. Redirection Methods
• Methods on the Controller class
• Return instances of redirection action methods
Permanent property set to true
• Types
RedirectPermanent method
RedirectToRoutePermanent method
RedirectToActionPermanent method
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
215. Redirection Methods
• Methods on the Controller class
• Return instances of redirection action methods
Permanent property set to true
• Types
RedirectPermanent method
RedirectToRoutePermanent method
RedirectToActionPermanent method
• Make easy to manage permanent redirections
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
216. Redirection Methods
• Methods on the Controller class
• Return instances of redirection action methods
Permanent property set to true
• Types
RedirectPermanent method
RedirectToRoutePermanent method
RedirectToActionPermanent method
• Make easy to manage permanent redirections
HTTP 301 status code
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
217. Learn More!
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
218. Learn More!
• This is an excerpt from a larger course. Visit
www.learnnowonline.com for the full details!
Learn More @ http://www.learnnowonline.com
Copyright © by Application Developers Training Company
Notas do Editor \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section, Final Selection\n DEMO: rest of section, Final Selection\n DEMO: rest of section, Final Selection\n DEMO: rest of section, Final Selection\n DEMO: rest of section, Final Selection\n DEMO: rest of section, Final Selection\n DEMO: rest of section, Final Selection\n DEMO: rest of section, Final Selection\n DEMO: rest of section, Final Selection\n DEMO: rest of section, Final Selection\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n DEMO: Render an HTML Page, Finding the View\n DEMO: most of rest of section\n DEMO: most of rest of section\n DEMO: most of rest of section\n DEMO: most of rest of section\n DEMO: most of rest of section\n DEMO: most of rest of section\n DEMO: most of rest of section\n DEMO: most of rest of section\n DEMO: most of rest of section\n \n \n \n \n \n \n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n DEMO: rest of section\n \n \n \n \n \n \n \n \n \n DEMO: rest of section\n