Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC SiteMap with Ninject controller factory error
    text
    copied!<p>I am trying to use the ASP.NET MVC Codeplex Sitemap project with Custom Dynamic Node provider. This is my node provider code. It uses some repository to access the DB. I actually don't use DI in this class but the application inherits NinjectHttpApplication and the Sitemap has problems acquiring controller.</p> <pre><code>public class ContentPageDynamicNodeProvider : DynamicNodeProviderBase { private IRepository _repository; public override IEnumerable&lt;DynamicNode&gt; GetDynamicNodeCollection() { // Build value var returnValue = new List&lt;DynamicNode&gt;(); // Create a node for each content page _repository = new XmlDefaultRepository(ContentType.Page); foreach(var page in _repository.GetInstances()) { DynamicNode node = new DynamicNode(); node.Title = page.Title; node.ParentKey = "Default"; node.RouteValues.Add("slug", page.Slug); returnValue.Add(node); } // Return return returnValue; } } </code></pre> <p>Then in Site.Master I try to render the breadcrumbs like this:</p> <pre><code>&lt;%=Html.MvcSiteMap().SiteMapPath() %&gt; </code></pre> <p>My default route that starts when running the site is Page/Display/{slug} and for slug I use the "Default", here is the global.asax.cs part</p> <pre><code> routes.MapRoute( "DefaultPage", RouteType.Regular, "", new { controller = "Page", action = "Display", slug = "Default" }, null ); routes.MapRoute( "PageBySlug", RouteType.Regular, "{slug}", new { controller = "Page", action = "Display", slug = "Default" }, null ); routes.MapRoute( "Default", RouteType.Regular, "{controller}/{action}/{slug}", new { controller = "Page", action = "Display", slug = "Default" }, null ); </code></pre> <p>The problem I have is that when Custom Site Node Provider is in place I get this error at runtime:</p> <p>Value cannot be null or empty. Parameter name: controllerName </p> <p>This is the stack trace (maybe it will help someone identify what is going on). As far as I can tell it goes to Ninject for controller but does not get one.</p> <blockquote> <p>[ArgumentException: Value cannot be null or empty. Parameter name: controllerName]<br> System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +167 Ninject.Web.Mvc.NinjectControllerFactory.CreateController(RequestContext requestContext, String controllerName) +151 MvcSiteMapProvider.AuthorizeAttributeAclModule.IsAccessibleToUser(IControllerTypeResolver controllerTypeResolver, DefaultSiteMapProvider provider, HttpContext context, SiteMapNode node) +533 MvcSiteMapProvider.DefaultAclModule.IsAccessibleToUser(IControllerTypeResolver controllerTypeResolver, DefaultSiteMapProvider provider, HttpContext context, SiteMapNode node) +149 MvcSiteMapProvider.DefaultSiteMapProvider.IsAccessibleToUser(HttpContext context, SiteMapNode node) +24<br> System.Web.SiteMapNode.IsAccessibleToUser(HttpContext context) +17<br> System.Web.SiteMapProvider.ReturnNodeIfAccessible(SiteMapNode node) +42<br> System.Web.StaticSiteMapProvider.FindSiteMapNode(String rawUrl) +176<br> MvcSiteMapProvider.DefaultSiteMapProvider.FindSiteMapNode(HttpContext context) +282<br> System.Web.SiteMapProvider.get_CurrentNode() +56 MvcSiteMapProvider.Web.Html.SiteMapPathHelper.SiteMapPath(MvcSiteMapHtmlHelper helper, String separator, String separatorCssClass, String linkCssClass, Boolean currentNodeAsLink, Object htmlAttributes) +81<br> MvcSiteMapProvider.Web.Html.SiteMapPathHelper.SiteMapPath(MvcSiteMapHtmlHelper helper) +30<br> ASP.views_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) +499</p> </blockquote> <p>Any help appreciated.</p> <p>Also please note that without the custom node provider (just the static nodes in .sitemap file) everything works fine.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload