Developer Guide
Controller Methods

    All public methods are considered actions of a controller. AspxController by default has only one action, which responds to HTTP GET requests as shown below.

    If your page name is: MyPage
     
    • /aspx/MyPage
    • /aspx/MyPage/Index
    In the above GET requests, "aspx" is defined as an "AREA", "MyPage" is the name of the controller as well as the name of the Activepage and "Index" is considered to be the "ACTION". Within the Magentrix platform, the default action is always "Index" and therefore is not a mandatory item to be included into the browser URL.
     
    You can add as many actions as you wish to your controller and then invoke them by typing them into the browser's URL. For example, you can define an action called "HelloWorld" and then invoke it via the URL below, using the example above:
     
    • /aspx/MyPage/HelloWorld

    Below the controller's code that implements the "HelloWorld" action:

    public class MyPageController : AspxController
    {
          public override ActionResponse Index()
          {
              return View();
          }
    
          public string HelloWorld()
          {
              return"Hello World";
          }
    }

     

    Rules around action methods

    When defining Magentrix action methods, you cannot use method overloads. Action names should be unique, with one exception; you can have two or more action methods with the same name only if they handle different HTTP verbs. 

    For example, one of the action method overloads is to handle GET request (initial load), and the subsequent one would be in charge of handling the POST back request (when a form on the page is submitted back).

    The code below shows how you can use the same method to handle GET and POST requests:

    public class MyPageController : AspxController
    {
        public override ActionResponse Index()
        {
            return View(new Contact());
        }
        
        [HttpPost]
        public ActionResponse Index(Contact model)
        {
             // do something
             return View(model);
        }
    }