-1

Hello So I'am trying to add multiple maps to project, in web config I write it like that:

 <siteMap defaultProvider="FullSiteMap">
  <providers>
    <clear />
    <add name="FullSiteMap" type="MvcSiteMapProvider.DefaultSiteMapProvider, MvcSiteMapProvider" siteMapFile="~/SiteMaps/Full.Sitemap" attributesToIgnore="visibility" />
    <add name="NonPrivateCoaching" type="MvcSiteMapProvider.DefaultSiteMapProvider, MvcSiteMapProvider" siteMapFile="~/SiteMaps/NonPrivateCoaching.Sitemap" attributesToIgnore="visibility" />
  </providers>
</siteMap>

After that I try to use it in View, like this:

@if(true)
{
     @Html.MvcSiteMap().Menu("BootstrapMenuHelperModel")
}
else
{
     @Html.MvcSiteMap().Menu("BootstrapMenuHelperModelNobPrivateCoaching")
}

Always it is using defaultProvider not for example second one. What is wrong here ?

2 Answers2

0

Your not choosing the provider:

@if(true)
{
     @Html.MvcSiteMap("FullSiteMap").Menu("BootstrapMenuHelperModel")
}
else
{
     @Html.MvcSiteMap("NonPrivateCoaching").Menu("BootstrapMenuHelperModelNobPrivateCoaching")
}

Using Multiple MvcSiteMaps

Community
  • 1
  • 1
Steve Greene
  • 12,029
  • 1
  • 33
  • 54
0

What do you mean it is always using defaultProvider? Your if/else statement doesn't make any sense? You have to define which site map provider you want to use. You don't do this here, so it will always take the default provider.

Change your code to something like this:

@Html.MvcSiteMap("YOURPROVIDEROFCHOICE").Menu() 
hbulens
  • 1,872
  • 3
  • 24
  • 45