5 <div class="container">
\r
8 Controllers are the main entry point for your application logic. They should
\r
9 invoke business methods, perform inputs validation and choose witch view
\r
10 should be rendered back to the user.
\r
14 To create your Controller, just extend the Controller class or SmartDispatcherController.
\r
15 Each public instance method will be considered a valid and accessible action. For example:
\r
19 namespace Yournamespace
\r
21 public class HomeController : Controller
\r
23 public void MyAction()
\r
27 public void OtherAction()
\r
35 Which can then be accessed from http://yourhost/yourvirtualdir/home/myaction.castle
\r
40 <h3>Properties and Methods</h3>
\r
42 <div class="container">
\r
45 The Controller class exposes a handful of properties and methods to common
\r
51 <li><strong>LayoutName</strong>: You can override </li>
\r
52 <li><strong>PropertyBag</strong>: Dictionary to pass data to the view</li>
\r
53 <li><strong>Session</strong>: Dictionary with a session scope</li>
\r
54 <li><strong>HttpContext</strong>: Access the underlying Asp.Net HttpContext</li>
\r
55 <li><strong>Request</strong>: Access a façade Request</li>
\r
56 <li><strong>Response</strong>: Access a façade Response</li>
\r
62 <li><strong>RenderView</strong>: Choose which view should be processed</li>
\r
63 <li><strong>Redirect</strong>: Send the user to another controller/action</li>
\r
64 <li><strong>CancelView</strong>: Skip the view processing</li>
\r
65 <li><strong>RenderText</strong>: Instead of processing a view, send the specified text</li>
\r
72 <h3>ControllerDetails attribute</h3>
\r
74 <div class="container">
\r
77 This attribute allows you to inform the framework about the controller's name and area.
\r
80 namespace Yournamespace
\r
82 [ControllerDetails("myhome", Area="myarea")]
\r
83 public class HomeController : Controller
\r
85 public void MyAction()
\r
93 Which will be accessible from http://yourhost/yourvirtualdir/myarea/myhome/myaction.castle
\r
101 <h3>Smart Dispatcher</h3>
\r
103 <div class="container">
\r
106 This Controller implementation tries to map form data to method arguments. Currently
\r
107 it supports Strings, primitive types, Guid and HttpPostedFile. The inputs on your form
\r
108 <b>must </b> have the same name of the method arguments.
\r
111 namespace Yournamespace
\r
113 public class AccountController : SmartDispatcherController
\r
115 public void Save(String name, String address, int age)
\r
123 And your form will look like:
\r
126 Name: <input type="text" name="name">
\r
127 Address: <input type="text" name="address">
\r
129 <select name="age">
\r
130 <option>18</option>
\r
131 <option>19</option>
\r
132 <option>20</option>
\r
133 <option>21</option>
\r