Sitecore MVC Area Controller Rendering Type

I saw this post a couple weeks back about working with Areas in Sitecore MVC. One of the issues was that you had to specify the view path in all of the actions because Sitecore didn’t understand what area you are in. To get around this I created my own rendering type that allows me to specify an Area field. The Area is then added to the Route Values Dictionary. I’m expecting this would also fix other problems with working in areas, like linking. I do however recomend that you strongly type the controller name when entering it as Sitecore is not using the Area field when it resolves the controller. Perhaps that code could be updated as well.

The code is here and the package to install it is here.

There are three classes that I will describe below :

This class checks to see if the Rendering Item inherits the Area Controller Template. If it does we Assign the AreaControllerRenderer as the Renderer.


This class passes the Action, Controller and Area to the AreaControllerRunner and returns the html to Sitecore.


This class executes the controller.  The big change is made here where I pass the Area in the Route Values Colleciton.  The important line to get area support is below.

requestContext.RouteData.DataTokens[“area”] = this.Area;


There is also a Sitecore.MVC.SitecoreAreas.config file that causes the code to execute in the GetRenderer Pipeline and a new template ‘Sitecore/Templates/User Defined/Mvc Areas/Area Controller’ that has the template to inherit from your rendering.

I personally think everything should be done in areas as it makes things more portable to other projects.  If you’re not using areas you can also use this project as a sample on how to extend Sitecore to support your own rendering type.


About Kevin Buckley
.Net web developer with a lot of experience in CMS. Currently working at Sitecore as Solutions Engineer.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: