MvcSiteMap: dynamic node provider not reached

I created a project that is defined by nodes using attributes, and I installed it in the web.config file to check for attributes, and it works great.
I do not use an XML file at all.

Now I want to add a dynamic node provider, how to do this?
Is there a way to do this without an XML file (.sitemap)?
I need to make sure that it is under the root that was installed in the code using the MvcSiteMapNodeAttribute attribute.

I read the documentation and I cannot figure out where to place this line:

 <mvcSiteMapNode title="Details" action="Details" dynamicNodeProvider="Project.StoreDetailsDynamicNodeProvider, Prject" /> 

What action should he indicate? Also, as said above, the root element is defined using attributes, so my question is whether there is a way to avoid XML or, alternatively, an efficient way to declare XML (all the better) to enable my dynamic provider.

Update

I tried the following and the node provider has not yet reached (From HomeController.cs).

 [MvcSiteMapNode(Title = "Home", Key = HomeMenuKey, DynamicNodeProvider = "Project.Namespace.NodeProvider, Assembly")] public ActionResult Index() { return View(); } 
+4
source share
2 answers
  • It seems that the dynamicNodeProvider attribute dynamicNodeProvider ignored in the root of the node, also when it is defined in the attributes.
    Thus, the only way to add a dynamic node provider to the root directory is to either point it to a dummy action, etc., or use XML.
  • An interesting note: the actual difference between the definition in XML and attributes is that if it is defined in attributes, it (i.e. menu items) will be the last in the menu, whereas if it is defined in XML, it will be right after Note that this can still be controlled using the Order property in the attributes.
  • In my Web.Config, I left siteMapFile empty, relying on what it said on the wiki page that the default value is ~/Web.sitemap , this is actually a lie (I already fixed this in the updated wiki ).
    I don’t think that this behavior should be like this, I think that the MvcSiteMap engine should scan for dynamic node providers in the same way that it scans dynamic node attributes ( this is the problem I posted on the site).
+1
source

Can you define it in the attributes of a controller method (and not use XML at all)?

For instance:

 [MvcSiteMapNode(Title="Details", DynamicNodeProvider = "Project.StoreDetailsDynamicNodeProvider, Project")] public ActionResult Index() { return View(); } 
+1
source

Source: https://habr.com/ru/post/1446253/


All Articles