Developer Guide
View Response

    Using this response type, you can indicate to the controller that you intend to load a current page:

    public ActionResponse Index()
    {
        return View();
    }

     

    Methods

    PropertyDescription
    View()Uses the default page associated with the current action
    View(*ActivePage)ActivePage Name and renders the requested page.
    View(object model)Uses the default view (current page) and passes Model to the it.
    View(* ActivePage, object model)Takes ActivePage Name and passes the Model to the page.

     

    Magentrix also allows you to use some of the predefined views that can be commonly used to show feedback to users in respect to system events. By passing the name of these views you can pass them to users.
     
    1. PageNotFound
      This view is used when the resource the user is looking for does not exist or has been removed
    2. RecordDeleted
      Use this view when the record the user is requesting to view has been deleted or they no longer has access to.
    3. UnderMaintenance
      Use this view to show that the system is under maintenance and not available.
    4. Error
      This view provides the basic visual items to show error messages to users. 
     

    Below is an example of a view showing the record has been deleted:

    public ActionResponse Index()
    {
        var con = Database.Query<Contact>().Where(f=>f.Id=="myId").FirstOrDefault();
        if (con==null)
           return RecordDeleted();
     
        return View(con);
    }


    Show a message with the error page:

    public ActionResponse Index()
    {
        return RedirectToError("My error message");
    } 
    

     

    Passing Active Templates or Pages in responses

    In many scenarios you may need to create several Active Templates- pages that are associated with a Controller- and use them as alternative views of data.

    For example, you may create an Active Page that shows a form to a user. Once this form is filled out and submitted, you want to show a confirmation message. To show this confirmation message, you can create a separate Active Template and return it as a view, as in the example below.

    public ActionResponse Index(Contact model)
    {
         if (Insert(model))
         {
              return View(ActivePages.MyConfirmPage, model);
         }
         else
         {
             //since the insert operation was not successful,
             // take the user back to the same screen where the errors are shown:
             return View(model);
         }
    }