2

I have created a custom Navigation controller for breadcrumb under the Navigations folder of my project module (DXA 1.7 .NET). However, I am getting the below error on every page:

The controller for path "requested page url" was not found or does not implement IController

Here is the Compoent Template: enter image description here

Here is the Project Structure:

enter image description here

I have added the entry in project Area Registration:

RegisterViewModel("Breadcrumb", typeof(NavigationLinks), "Navigations");

Also here is the code for the NavigationsController:

public class NavigationsController : NavigationController
{
    public override ActionResult Navigation(EntityModel entity, string navType, int containerSize = 0)
    {
        if (navType.Trim().ToLower() == "topmenu")
        {
            SitemapItem model = SiteConfiguration.NavigationProvider.GetNavigationModel(WebRequestContext.Localization);
            EntityModel sourceModel = (EnrichModel(entity) as EntityModel) ?? entity;
            model.XpmMetadata = sourceModel.XpmMetadata;
            model.XpmPropertyMetadata = sourceModel.XpmPropertyMetadata;
            return View(sourceModel.MvcData.ViewName, model);
        }
        else
        {
            return base.Navigation(entity, navType, containerSize);
        }
    }
}

Here is the entry in Global.asax

// Navigation JSON
routes.MapRoute(
    "Core_Navigation",
    "navigation.json",
    new { controller = "Navigations", action = "SiteMapJson" }
).DataTokens.Add("area", "XXX");
routes.MapRoute(
    "Core_Navigation_loc",
     "{localization}/navigation.json",
     new { controller = "Navigations", action = "SiteMapJson" }
).DataTokens.Add("area", "XXX");

Please suggest If I have missed anything here? I am not sure why it is showing the Page URL in the error message? I have looked into a similar issue (DXA Custom Controller Issue (Routing)) posted on stack previously, but its scenario is different.

Here is the full StackTrace :

` StackTrace " at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.Wrap[TResult](Func1 func)\r\n at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerAsyncWrapper.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)\r\n at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)\r\n at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage)\r\n at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm)\r\n at System.Web.HttpServerUtilityWrapper.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm)\r\n at System.Web.Mvc.Html.ChildActionExtensions.ActionHelper(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues, TextWriter textWriter)\r\n at System.Web.Mvc.Html.ChildActionExtensions.Action(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues)\r\n at Sdl.Web.Mvc.Html.HtmlHelperExtensions.DxaEntity(HtmlHelper htmlHelper, EntityModel entity, Int32 containerSize)\r\n at Sdl.Web.Mvc.Html.HtmlHelperExtensions.DxaEntities(HtmlHelper htmlHelper, Int32 containerSize)\r\n at ASP._Page_Areas_XXX_Views_Region_BreadcrumbContainer_cshtml.Execute() in c:\D\Projects\XXX\WebSite-SouceCode\XXX\Areas\XXX\Views\Region\BreadcrumbContainer.cshtml:line 2\r\n at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()\r\n at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()\r\n at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)\r\n
at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)\r\n at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)\r\n at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)\r\n at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)\r\n at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)\r\n
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)" string

`

  • What is the full stack trace of the error? – Rick Pannekoek Nov 14 '17 at 15:20
  • Why do you change the routes for navigation.json in Global.asax ? It seems your custom navigation controller doesn't override the SiteMapJson action? – Rick Pannekoek Nov 14 '17 at 15:22
  • @RickPannekoek, I have added the StackTrace. – Sayantan Basu Nov 14 '17 at 16:44
  • Try putting your Controller in the same namespace as your AreaRegistration class. – Rick Pannekoek Nov 14 '17 at 20:49
  • Oh. I will try that and confirm. – Sayantan Basu Nov 15 '17 at 11:34
2

ASP.NET MVC use a bit of magic to find Controller classes. By default, it assumes that Controllers are in the same namespace as the AreaRegistration class (or a sub namespace).

Given your project structure, it seems this is not the case and hence the Controller cannot be found. You could change the namespace of your Controller or AreaRegistration class.

Alternatively, you can add namespaces to the AreaRegistrationContext. See, for example: https://github.com/sdl/dxa-web-application-dotnet/blob/release/1.7/Sdl.Web.Mvc/Configuration/BaseAreaRegistration.cs

| improve this answer | |

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.