Sitecore MVC Controller Rendering

Posted by Xing Liu on 11/13/2015

This blog post will describe the steps on how to create controller rendering in Sitecore MVC.  One of the benefits of using controller rendering is to set aside the complex logic in the MVC controller.

First, you need to create a definition item in the Sitecore tree.

Controller rendering

Fill in the following two fields with the controller name and the action name that you want to invoke.

Definition item

Once the definition item is created, you can create a corresponding Controller in the Controller s folder with the same action name stated in the definition item.

Below is an example of how you can invoke a form post action in the cshtml file.

@using (Html.BeginForm("ActionName", "ControllerName", FormMethod.Post))
        <div class="form-group">
        <input type="hidden" id="sitecoreitemid" name="sitecoreitemid" value="@idString" />
        <button type="submit" class="btn btn-primary">Submit</button>

Finally, make sure you include the following attribute on top of the action function.

public ActionResult ControllerAction(Guid sitecoreitemid)
//Controller Action


Looking for a partner who will exceed your expectations? Get in touch.

SYMSOFT SOLUTIONS 4090 Truxel Road, Suite 200 Sacramento, CA 95834
United States (916) 567-1740