Developer Guide
Redirect Response

    If you wish to redirect the user to a different page or website address as a response to an HTTP request (Status Code:302), use the Redirect response as shown below:

    public ActionResponse MyRedirectAction()
    {
        return Redirect("~/home/index");
    }
     
    If you wish to redirect the user permanently (Status Code:301), use the RedirectPermanent resource:
     
    public ActionResponse MyRedirectAction()
    {
        return RedirectPermanent("/home/index");
    }
     

    Using the above statement, the system will redirect the user to the Home page. The "~" sign allows you to let the system figure out the relative path and redirect the user to the proper page.

     
    There are other types of redirect responses in Magentrix that help you quickly redirect the user to a different action either on the same controller or a different one:
     
    • RedirectToAction(string actionName, object routeValues)
    • RedirectToAction(string actionName, string controllerName, object routeValues)
    • RedirectToActionPermanent(string actionName, object routeValues)
    • RedirectToActionPermanent(string actionName, string controllerName, object routeValues)
     

    Example of redirecting the user to a Contact/Edit page:

    public override ActionResponse Index()
    {
        Contact contact = Database.Retrieve<Contact>("00700000000002b0000");
        return RedirectToAction("Edit","Contact", new { Id=contact.Id, firstName=contact.FirstName });
    }

     

    Redirecting To Another Active Page

    In order to redirect to another active page, we recommend the following method, which helps you maintain the system dependencies in check and allows the system to notify you when active page is referenced somewhere in your code:

    publicoverride ActionResponse Index()
    {
         return Redirect(ActivePages.YourOtherPageName);
    }
     

    If you need to redirect to an Active Page and also pass parameters, you can pass the parameters using an anonymous object or RouteValueDictionary:

    public ActionResponse MyAction()
    {
        return Redirect(ActivePages.MyPage, new { id=3, mode="view" });
    }