Working with Controllers and Actions in MVC

707 views
653 views

Published on

Learn how controllers manage MVC applications and how action methods can receive input.

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
707
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • \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
  • Working with Controllers and Actions in MVC

    1. 1. Working withControllers and Actionsin MVC Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    2. 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. 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
    4. 4. Introduction to Controllers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    5. 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. 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. 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. 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. 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. 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. 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. 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. 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. 14. Using a Controller to Manage theApplication Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    15. 15. Using a Controller to Manage theApplication • Powerful but easy to use Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    16. 16. Using a Controller to Manage theApplication • 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. 17. Using a Controller to Manage theApplication • 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. 18. Using a Controller to Manage theApplication • 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. 19. Using a Controller to Manage theApplication • 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
    20. 20. Controllers in System.Web.Mvc Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    21. 21. Controllers in System.Web.Mvc• Controller must: Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    22. 22. Controllers in System.Web.Mvc• Controller must:  Implement IController interface Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    23. 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. 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. 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. 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. 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. 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. 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. 30. The IController Interface Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    31. 31. The IController Interface• IController requirement isn’t onerous Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    32. 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. 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. 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. 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. 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. 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. 38. The ControllerBase Abstract BaseClass Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    39. 39. The ControllerBase Abstract BaseClass • Implements IController Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    40. 40. The ControllerBase Abstract BaseClass • Implements IController  Adds controller features, such as TempData and ViewData Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    41. 41. The ControllerBase Abstract BaseClass • 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. 42. The ControllerBase Abstract BaseClass • 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. 43. The ControllerBase Abstract BaseClass • 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. 44. The ControllerBase Abstract BaseClass • 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. 45. The Controller Class Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    46. 46. The Controller Class• Rich implementation of controller infrastructure Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    47. 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. 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. 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. 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. 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. 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. 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. 54. The MVC Request Processing Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    55. 55. The MVC Request Processing• Response process to every user request Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    56. 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. 57. The MVC Request Processing• Response process to every user request  IIS, ASP.NET, MVC collaborationRequest Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    58. 58. The MVC Request Processing• Response process to every user request  IIS, ASP.NET, MVC collaborationRequest HTTP Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    59. 59. The MVC Request Processing• Response process to every user request  IIS, ASP.NET, MVC collaborationRequest HTTP Routing Engine Controller Factory Controller View Action Method Action Invoker Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    60. 60. The MVC Request Processing• Response process to every user request  IIS, ASP.NET, MVC collaborationRequest 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. 61. The MVC Request Processing• Response process to every user request  IIS, ASP.NET, MVC collaborationRequest 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. 62. Action Method Selection Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    63. 63. Action Method Selection• Job of the action invoker Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    64. 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. 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. 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. 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. 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. 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. 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. 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
    72. 72. Action Method Qualifications Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    73. 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. 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. 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. 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. 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. 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. 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. 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. 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. 82. ActionName Attribute Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    83. 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. 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. 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. 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. 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
    88. 88. ActionMethodSelector Attribute Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    89. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 99. Controller Actions Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    100. 100. Controller Actions• Once invoked, action method does its job Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    101. 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. 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. 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. 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. 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. 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. 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. 108. Action Method Input Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    109. 109. Action Method Input• Most methods need data to do work Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    110. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 120. Context Object Input Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    121. 121. Context Object Input• Web requests come loaded with information Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    122. 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. 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. 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. 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. 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. 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. 128. Parameter Input Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    129. 129. Parameter Input• Specialized input customized for method Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    130. 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. 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. 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. 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. 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. 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. 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. 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. 138. Model Bindings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    139. 139. Model Bindings• Model encapsulates data and business rules Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    140. 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. 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. 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. 143. Controller Session State Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    144. 144. Controller Session State• SessionState attribute Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    145. 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. 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. 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. 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. 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. 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. 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. 152. Returning Action Results Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    153. 153. Returning Action Results• Action method follows a normal process Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    154. 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. 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. 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. 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. 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. 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. 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. 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. 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. 163. Action Result Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    164. 164. Action Result• ActionResult base class Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    165. 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. 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. 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. 168. ActionResult Types Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    169. 169. ActionResult TypesType Helper Method DescriptionContentResult Content() Raw text dataEmptyResult -- Returns nothingFileResult File() Base class to send fileHttpNotFoundResult HttpNotFound() Returns HTTP 404HttpStatusCodeResult -- Returns any HTTP statusHttpUnauthorizedResult -- Returns HTTP 401JavaScriptResult JavaScript() Returns and executes scriptJsonResult Json() JavaScript Object NotationPartialViewResult PartialView() HTML snippetRedirectResult Redirect() Redirect to URLRedirectToRouteResult RedirectToRoute() Redirect to MVC route or actionViewResult RedirectToAction() View() Full HTML page Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    170. 170. Passing Data to the View Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    171. 171. Passing Data to the View• Use either ViewData or ViewBag Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    172. 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. 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. 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. 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. 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. 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. 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. 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. 180. ViewData and ViewBag Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    181. 181. ViewData and ViewBag• Not limited to passing strings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    182. 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. 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. 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. 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. 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. 187. Returning Text Data: ContentResult Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    188. 188. Returning Text Data: ContentResult • HTML is dominant data format Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    189. 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. 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. 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. 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. 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. 194. Implicit Action Results Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    195. 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. 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. 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. 198. Missing Resource: Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    199. 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. 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. 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. 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. 203. Return any HTTP Status Code: Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    204. 204. Return any HTTP Status Code:• More flexible than HttpNotFoundResult Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    205. 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. 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. 207. Redirection Methods Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    208. 208. Redirection Methods• Methods on the Controller class Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    209. 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. 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. 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. 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. 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. 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. 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. 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. 217. Learn More! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
    218. 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

    ×