Controller Name Collisions with Sitecore SXA

Are you looking to install Sitecore Experience Accelerator, or moving to Sitecore Managed Cloud (which bundles Sitecore Experience Accelerator (SXA) with Managed Cloud deployments)? If so, there are dozens of controllers included with SXA that may cause issues with existing Sitecore solutions. With a quick modification to your layout definition items, you can avoid conflicts between your custom controllers and those included by SXA.

I recently started seeing errors like the one below on a Sitecore solution that had upgraded to a newer version of Sitecore on Sitecore Managed Cloud with SXA installed.

Exception: Sitecore.Mvc.Diagnostics.ControllerCreationException
Message: Could not create controller: 'Navigation'. 
....
Nested Exception

The request for 'Navigation' has found the following matching controllers:
Sitecore.XA.Feature.Navigation.Controllers.NavigationController
{brandName}.Web.Controllers.{brandName}.NavigationController
Source: System.Web.Mvc
   at System.Web.Mvc.DefaultControllerFactory.GetControllerTypeWithinNamespaces(RouteBase route, String controllerName, .....)

This didn’t just occur for one controller, either – the reason for that is that there are nearly **90** controllers included in SXA. Since SXA is meant to provide implementations of commonly required features, so it makes sense that they would have controllers with the same name as those found in many Sitecore solutions.

Some SXA include controller names that seem common to many projects are:

  • LoginController
  • NavigationController
  • ImageController
  • VideoController
  • LinkController
Full list of SXA controllers:
  • SkipLinkController (in Sitecore.XA.Feature.Accessibility.Controllers)
  • GoogleAnalyticsController (in Sitecore.XA.Feature.Analytics.Controllers)
  • PrivacyWarningController (in Sitecore.XA.Feature.Compliancy.Controllers)
  • AccordionController (in Sitecore.XA.Feature.Composites.Controllers)
  • CarouselController (in Sitecore.XA.Feature.Composites.Controllers)
  • CompositeComponentController (in Sitecore.XA.Feature.Composites.Controllers)
  • FlipController (in Sitecore.XA.Feature.Composites.Controllers)
  • SnippetController (in Sitecore.XA.Feature.Composites.Controllers)
  • TabsController (in Sitecore.XA.Feature.Composites.Controllers)
  • LanguageSelectorController (in Sitecore.XA.Feature.Context.Controllers)
  • SiteSelectorController (in Sitecore.XA.Feature.Context.Controllers)
  • DisqusController (in Sitecore.XA.Feature.Engagement.Controllers)
  • FacebookCommentsController (in Sitecore.XA.Feature.Engagement.Controllers)
  • EventCalendarController (in Sitecore.XA.Feature.Events.Controllers)
  • EventListController (in Sitecore.XA.Feature.Events.Controllers)
  • HtmlSnippetController (in Sitecore.XA.Feature.GenericMetaRendering.Controllers)
  • HorizonDataSourceApiController (in Sitecore.XA.Feature.Horizon.Controllers)
  • HorizonDatasourceEditingApiController (in Sitecore.XA.Feature.Horizon.Controllers)
  • HorizonMetadataApiController (in Sitecore.XA.Feature.Horizon.Controllers)
  • JsonContentController (in Sitecore.XA.Feature.Json.Controllers)
  • JsonListController (in Sitecore.XA.Feature.Json.Controllers)
  • JsonResultsController (in Sitecore.XA.Feature.Json.Controllers)
  • PageLayoutJsonController (in Sitecore.XA.Feature.LayoutServices.Integration.Controllers)
  • MapController (in Sitecore.XA.Feature.Maps.Controllers)
  • FileListController (in Sitecore.XA.Feature.Media.Controllers)
  • FlashController (in Sitecore.XA.Feature.Media.Controllers)
  • GalleryController (in Sitecore.XA.Feature.Media.Controllers)
  • ImageController (in Sitecore.XA.Feature.Media.Controllers)
  • MediaLinkController (in Sitecore.XA.Feature.Media.Controllers)
  • PlaylistController (in Sitecore.XA.Feature.Media.Controllers)
  • VideoController (in Sitecore.XA.Feature.Media.Controllers)
  • ArchiveController (in Sitecore.XA.Feature.Navigation.Controllers)
  • BreadcrumbController (in Sitecore.XA.Feature.Navigation.Controllers)
  • LinkController (in Sitecore.XA.Feature.Navigation.Controllers)
  • LinkListController (in Sitecore.XA.Feature.Navigation.Controllers)
  • NavigationController (in Sitecore.XA.Feature.Navigation.Controllers)
  • OverlayLayoutController (in Sitecore.XA.Feature.Overlays.Controllers)
  • PageListController (in Sitecore.XA.Feature.PageContent.Controllers)
  • PaginationController (in Sitecore.XA.Feature.PageContent.Controllers)
  • PlainHTMLController (in Sitecore.XA.Feature.PageContent.Controllers)
  • RichTextController (in Sitecore.XA.Feature.PageContent.Controllers)
  • TitleController (in Sitecore.XA.Feature.PageContent.Controllers)
  • ColumnSplitterController (in Sitecore.XA.Feature.PageStructure.Controllers)
  • ContainerController (in Sitecore.XA.Feature.PageStructure.Controllers)
  • DividerController (in Sitecore.XA.Feature.PageStructure.Controllers)
  • EditModePanelController (in Sitecore.XA.Feature.PageStructure.Controllers)
  • IFrameController (in Sitecore.XA.Feature.PageStructure.Controllers)
  • RowSplitterController (in Sitecore.XA.Feature.PageStructure.Controllers)
  • ToggleController (in Sitecore.XA.Feature.PageStructure.Controllers)
  • ChecklistFilterController (in Sitecore.XA.Feature.Search.Controllers)
  • DateFilterController (in Sitecore.XA.Feature.Search.Controllers)
  • DropdownFilterController (in Sitecore.XA.Feature.Search.Controllers)
  • FacetSliderController (in Sitecore.XA.Feature.Search.Controllers)
  • FacetSummaryController (in Sitecore.XA.Feature.Search.Controllers)
  • LoadMoreController (in Sitecore.XA.Feature.Search.Controllers)
  • LocationFilterController (in Sitecore.XA.Feature.Search.Controllers)
  • ManagedRangeFilterController (in Sitecore.XA.Feature.Search.Controllers)
  • PageSelectorController (in Sitecore.XA.Feature.Search.Controllers)
  • PageSizeController (in Sitecore.XA.Feature.Search.Controllers)
  • RadiusFilterController (in Sitecore.XA.Feature.Search.Controllers)
  • RangeSliderFilterController (in Sitecore.XA.Feature.Search.Controllers)
  • ResultsCountController (in Sitecore.XA.Feature.Search.Controllers)
  • ResultsVariantSelectorController (in Sitecore.XA.Feature.Search.Controllers)
  • SearchBoxController (in Sitecore.XA.Feature.Search.Controllers)
  • SearchController (in Sitecore.XA.Feature.Search.Controllers)
  • SearchResultsController (in Sitecore.XA.Feature.Search.Controllers)
  • SortResultsController (in Sitecore.XA.Feature.Search.Controllers)
  • LoginController (in Sitecore.XA.Feature.Security.Controllers)
  • LoginPageController (in Sitecore.XA.Feature.Security.Controllers)
  • LogoutController (in Sitecore.XA.Feature.Security.Controllers)
  • SocialLoginWrapperController (in Sitecore.XA.Feature.Security.Controllers)
  • ControllerRendering (in Sitecore.XA.Feature.Security.Renderings)
  • BrowserTitleController (in Sitecore.XA.Feature.SiteMetadata.Controllers)
  • CanonicalUrlController (in Sitecore.XA.Feature.SiteMetadata.Controllers)
  • CustomMetadataController (in Sitecore.XA.Feature.SiteMetadata.Controllers)
  • FaviconController (in Sitecore.XA.Feature.SiteMetadata.Controllers)
  • MetadataController (in Sitecore.XA.Feature.SiteMetadata.Controllers)
  • OpenGraphMetadataController (in Sitecore.XA.Feature.SiteMetadata.Controllers)
  • SeoMetadataController (in Sitecore.XA.Feature.SiteMetadata.Controllers)
  • TwitterMetadataController (in Sitecore.XA.Feature.SiteMetadata.Controllers)
  • ViewportController (in Sitecore.XA.Feature.SiteMetadata.Controllers)
  • AddThisController (in Sitecore.XA.Feature.Social.Controllers)
  • FeedController (in Sitecore.XA.Feature.Social.Controllers)
  • SocialMediaShareController (in Sitecore.XA.Feature.Social.Controllers)
  • TwitterController (in Sitecore.XA.Feature.Social.Controllers)
  • StickyNoteController (in Sitecore.XA.Feature.StickyNotes.Controllers)
  • TagCloudController (in Sitecore.XA.Feature.Taxonomy.Controllers)
  • TagListController (in Sitecore.XA.Feature.Taxonomy.Controllers)
  • DynamicPlaceholdersController (in Sitecore.XA.Foundation.DynamicPlaceholders.Controller)
  • ExcludeMvcControllerResolutionAttribute (in Sitecore.XA.Foundation.IoC.Attributes)
  • IControllerRepository (in Sitecore.XA.Foundation.IoC)
  • RegisterMvcControllersIoC (in Sitecore.XA.Foundation.IoC.ServiceCollection)
  • RenderingDataSourceController (in Sitecore.XA.Foundation.LocalDatasources.Controllers)
  • ControllerRendering (in Sitecore.XA.Foundation.LocalDatasources.Templates)
  • StandardController (in Sitecore.XA.Foundation.Mvc.Controllers)
  • SxaLayoutController (in Sitecore.XA.Foundation.Mvc.Controllers)
  • PaginableController (in Sitecore.XA.Foundation.RenderingVariants.Controllers.Base)
  • VariantsController (in Sitecore.XA.Foundation.RenderingVariants.Controllers)
  • ControllerRendering (in Sitecore.XA.Foundation.RenderingVariants.Templates)
  • FakeController (in Sitecore.XA.Foundation.SitecoreExtensions.Services.RazorService)
  • SessionHttpControllerHandler (in Sitecore.XA.Foundation.SitecoreExtensions.Session)
  • SessionHttpControllerRouteHandler (in Sitecore.XA.Foundation.SitecoreExtensions.Session)
  • ControllerRendering (in Sitecore.XA.Foundation.SitecoreExtensions.Templates)
  • VariantsApiController (in Sitecore.XA.Foundation.Variants.Abstractions.Controllers)
  • VariantsSwitcherController (in Sitecore.XA.Foundation.Variants.Abstractions.Controllers)

You can see how there might be a few collisions when including SXA in an existing, feature-rich Sitecore solution. To get around this, you can fully qualify controller names in controller renderings as shown. In the controller field, you can provide the full namespace of the controller, along with the assembly name.

With this quick edit to your controller layout items, you can prevent this issue from occurring when adding SXA to your site.

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *