Get more content like this

Sitecore 8.1 Now Supports MVC Areas

Sitecore supports MVC areas
By

Model View Controller (MVC) “Areas” represent a handy module-based way to separate and manage different aspects of a website’s development. As you may know, the concept of “Areas” has been an integral part of ASP.NET MVC ever since ASP.NET MVC 2 launched in 2010. However, Sitecore has not offered an easy-and-comprehensive way to support MVC Areas—until now.

When Sitecore 8.1 officially launched in October 2015, it brought a host of new features that have simplified everything. With these new tools, developers no longer need to spend their time creating custom frameworks and writing custom rules to address MVC Areas. Instead, they have a much faster (and more streamlined) process, which ultimately speeds development time.

Along with default implementations, Sitecore 8.1 now provides a way for users to define their own Area resolver by implementing the “IAreaResolveStrategy” interface. This interface introduces two new concepts.

The first is a new processor called “ResolveArea,” now available in the Sitecore.Mvc.config file for resolving Areas. Within this processor configuration, various configurable area-resolving strategies are available to help users resolve an Area for current rendering. The call to a strategy is made serially, one after the other, until the currently called strategy resolves the area.

The default strategy used is ChainedAreaResolveStrategy, another new concept. This assists in configuring multiple resolvers, which are called in a chain. If there is only one resolver, this strategy can be changed.

Three Ways Sitecore 8.1 Can Resolve MVC Areas

Not only do they provide additional support to MVC Areas, they can be used in three ways to identify and resolve an area:

  1. Resolve by rendering a definition item – In rendering a definition item, the area of the Controller/View can be configured with one limitation—that the Controller field should either contain the unique Controller name or the fully qualified name of the Controller class.
  2. Resolve by rendering parameters – While adding a rendering to the presentation of an item (either statically or dynamically bound), a rendering parameter area can be added to rendering.
  3. Resolve by layout definition – Apart from the rendering definition items, the layout definition items also got a new Area field. This strategy takes the area from the layout attached to the current item. This reflects that each rendering of the current item takes the same area, as long as no other strategy has ever resolved that area.

If these strategies aren’t required, they can be removed from the configuration.

Need Assistance?

TechAspect has deep expertise implementing all things Sitecore. If you need help using Sitecore 8.1 features to their fullest, ? Contact us today.

Need help powering your website with Sitecore?

Get In Touch