asp.net mvc 5 - MvcSiteMapProvider MVC5 External URL Re-routing to Home Controller / Index Method -


i'm using mvcsitemapprovider 4.6.18. many of menu items link external sites; however, "url" attribute of mvcsitemapnode not being carried on menu. is, can see url in source, link referring parent mvcsitemapnode controller , action , not url specified.

here's relevant code:

<?xml version="1.0" encoding="utf-8" ?> <mvcsitemap xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"   xmlns="http://mvcsitemap.codeplex.com/schemas/mvcsitemap-file-4.0"   xsi:schemalocation="http://mvcsitemap.codeplex.com/schemas/mvcsitemap-file-4.0 mvcsitemapschema.xsd">  <mvcsitemapnode title="home" controller="home" action="index">     <mvcsitemapnode title="about" url="http://www.amazon.com"/> </mvcsitemapnode>  </mvcsitemap> 

and here's see when viewing source:

<li>     <a href="/"><span class="menu-text">about</span></a> </li> 

it doesn't matter use url, points root (i.e. home).

there seems simple i'm missing. life of me, can't figure out. completeness, here's routeconfig:

public class routeconfig {     public static void registerroutes(routecollection routes)     {         routes.ignoreroute("{resource}.axd/{*pathinfo}");          routes.maproute(             name: "default",             url: "{controller}/{action}/{id}",             defaults: new { controller = "home", action = "index", id = urlparameter.optional }         );     } } 

any appreciated.

update

thanks @nightowl888, issue 1 of display templates. mvcsitemapprovider part of bootstrap theme template downloaded wrapbootstrap , didn't think @ display templates possible issue.

here's offending template, modified original nuget download work custom side bar menu.

@model mvcsitemapprovider.web.html.models.menuhelpermodel @using system.web.mvc.html @using mvcsitemapprovider.web.html.models  <ul class="nav sidebar-menu">    @showmenu(model.nodes) </ul>  @helper showmenu(ienumerable<sitemapnodemodel> menuitems) {    foreach (var node in menuitems)    {       var nodeclass = "";       if (node.iscurrentnode)       {          nodeclass = "active";       }       if (node.children.any(n => n.iscurrentnode))       {          nodeclass = "active open";       }       else if (node.children.any())       {          foreach (var c in node.children)          {             if (c.children.any())             {                if (c.children.any(n => n.iscurrentnode))                {                   nodeclass = "active open";                }             }          }       }       <li class="@(!string.isnullorempty(nodeclass) ? html.raw(nodeclass) : null)">          @if (node.children.any())          {             @html.bootstrap().sidebarmenuitem(node.title, node.area, node.action, node.controller).icon(node.imageurl).isdropdown();          }          else          {             @html.bootstrap().sidebarmenuitem(node.title, node.area, node.action, node.controller).icon(node.imageurl);          }          @if (node.children.any())          {             <ul class="submenu">                @showmenu(node.children)             </ul>          }       </li>    } } 

mvcsitemapprovider driven html helpers. since cannot reproduce problem v4.6.18 , mvc5, suspect have not added 1 view.

a typical case add menu html helper /views/shared/_layout.cshtml page, follows.

<div class="navbar-collapse collapse">     @*<ul class="nav navbar-nav">         <li>@html.actionlink("home", "index", "home")</li>         <li>@html.actionlink("about", "about", "home")</li>         <li>@html.actionlink("contact", "contact", "home")</li>     </ul>*@     @* use mvcsitemapprovider menu html helper *@     @html.mvcsitemap().menu()     @html.partial("_loginpartial") </div> 

tip: if update mvcsitemapprovider.web package version 4.6.18, bootstrap css classes output on menu html helper, blend default mvc 5 theme. run command pm> update-package mvcsitemapprovider.web -safe package manager console update.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -