Sitecore MVC Controller Rendering

Xing Liu • 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

Xing Liu

Xing has 5 years of experience with developing web solutions using ASP.NET and SQL Server. For the past 3 years, he has been actively engaged in website development projects using Sitecore CMS. He enjoys creating web solutions for clients using Sitecore CMS and, using its flexibility, provides cohesive and integrated solutions. Xing is a Sitecore Technology MVP, 2016.

Explore topics:

Other Blog Posts from Xing Liu

Subscribe for insights, trends and big ideas