2

We have a requirement to work with MVC Areas in Sitecore 8.2 Update1 CMS application.

We tried to use the Area field in Item definition, but view engine is still searching in the default controller path (instead of areas).

Can anybody please help with any example or documentation of implementing MVC areas with Sitecore 8.2 Update1

2
  • 1
    Did you register the area using the AreaRegistration? – Hishaam Namooya Jun 13 '17 at 15:50
  • Can you show us your code? – Zachary Kniebel Jun 13 '17 at 16:34
4

For each MVC rendering, the pipeline mvc.renderRendering is called. In the Sitecore.Mvc.config there is a new processor ResolveArea configured for this pipeline. Within the processor configuration, you can configure a list of area resolving strategies, which are responsible for resolving the area for the current rendering: Each strategy is called after each other, until one strategy can resolve the area.

The configuration looks like:

enter image description here

As you can see, the default resolver is ChainedAreaResolveStrategy. This allows you to configure multiple resolvers which are called in a chain. If you know that you will always only have exactly one resolver, you could also change this.

Available strategies By default, there are three strategies available. The following paragraphs describe all of them. Of course you can remove these strategies from the configuration if you don’t need it.

Resolve by rendering definition item In the controller rendering definition item, there is a new field Area:

enter image description here

The area token is mostly used for the view resolution in your controllers and views, not for resolving your controller from the definition item. Please consider that Sitecore still needs a unique controller name in your rendering definition items. You either need to have a unique controller name or add the full name of the controller class into the Controller field.

Resolve by rendering parameters

When adding a rendering to the presentation of your item (statically or dynamically binded) you can add rendering parameters. This strategy allows to add a parameter area. For a statically binded rendering in the code, this could look like this:

@Html.Sitecore().Rendering("<path or id>", new { area = "MyArea" })

Resolve by layout definition

Similar to the rendering definition items, also the layout definition items got a new Area field. This strategy takes the area from the layout attached to the current item. Of course this means that each rendering of the current item takes the same area (if no other strategy has resolved the area before).

More informations you can find here: https://ctor.io/new-in-sitecore-8-1-mvc-areas/

2
  • Can you please provide an example of the implementation – Hari Prasad Kotha Jun 19 '17 at 11:28
  • I can not , you have all the information on the link I provide you – Vlad Iobagiu Jun 19 '17 at 11:48
0

Did you follow the instructions from here: https://doc.sitecore.net/sitecore_experience_platform/developing/developing_with_sitecore/mvc/mvc_areas ?

Check that you have the processor: Sitecore.Mvc.Pipelines.Response.RenderRendering.ResolveArea, Sitecore.Mvc in your App_Config/Include/Sitecore.Mvc.config file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.