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:
Here is the Project Structure:
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
`
navigation.json
inGlobal.asax
? It seems your custom navigation controller doesn't override theSiteMapJson
action?