In the DXA Example Site a RegionName is set in the ViewBag. Where is this defined?


if (ViewBag.RegionName == "Hero")
  • Do you mean when the RegionName is added to the ViewBag, why is that important exactly? – Bart Koopman May 4 '17 at 12:30
  • How is it added and from where? Would like to understand how it is working. – robrtc May 4 '17 at 12:41

The ViewBag.RegionName contains a bit of context information for the view. It is populated by the DXA controllers, (see Sdl.Web.Mvc.Controllers.SetupViewData). It does not apply to page views and region views.

Which RegionName is used is configured in the CT (component template) in the CMS, in the template metadata field Region Name. If the Region Name field is empty the default is the region view name (excluding module name) from the Region View Name field.

The Core module uses the Viewbag.RegionName in the partial view Teaser-ImageOverlay (see source).

 if (ViewBag.RegionName == "Hero")

RegionName is set in the corresponding ComponentTemplate's RegionView Field

  • 1
    Actually the RegionName comes from the Region Name field. Only when that is empty the Region View Name is used. – Jan H May 4 '17 at 13:44

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.