title: Load an XML sitemap into MvcSiteMapProvider based on user role
body: <p>I have installed v4 of MvcSiteMapProvider and now I want to load a sitemap dynamically. My needs are simple - load an XML sitemap on each page request based on the currently logged in user role eg. AdminSiteMap.xml and UserSiteMap.xml</p>
  
  <p>It appears that this can be done:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/19042744/using-asp-net-mvcsitemapprovider-v4-with-2-sitemap">Using asp.net MVCSiteMapProvider v4 with 2 sitemap</a></li>
  <li><a href="https://github.com/maartenba/MvcSiteMapProvider/wiki/Multiple-Sitemaps-in-One-Application" rel="nofollow noreferrer">https://github.com/maartenba/MvcSiteMapProvider/wiki/Multiple-Sitemaps-in-One-Application</a></li>
  </ul>
  
  <p>So basically you need to use a DI to achieve this (<strong>overkill IMHO</strong>). Any chance this can be done <em>without</em> a DI?</p>
  
  <p>So as I am using ASP Boilerplate (<a href="http://www.aspnetboilerplate.com/" rel="nofollow noreferrer">http://www.aspnetboilerplate.com/</a>) I have Castle Windsor as my DI.</p>
  
  <p>So I installed "MvcSiteMapProvider MVC5 Windsor Dependency Injection Configuration" via NuGet. However now when I run the app I get the following error:</p>
  
  <p>The SiteMapLoader has not been initialized.</p>
  
  <pre><code>Check the 'MvcSiteMapProvider_UseExternalDIContainer' setting in the AppSettings section of web.config.
  
  If the setting is set to 'false', you will need to call the MvcSiteMapProvider.DI.Composer.Compose() method at the end of Application_Start in the Global.asax file. Alternatively, if you are using .NET 4.0 or higher you can install the MvcSiteMapProvider.MVCx NuGet package corresponding to your MVC version.
  
  If the setting is set to 'true', you must set the SiteMaps.Loader property during Application_Start in Global.asax to an instance of the built-in SiteMapLoader type or a custom ISiteMapLoader instance. This can be achieved most easily by using your external DI container.
  </code></pre>
  
  <p>I have not changed the default configuration and have confirmed that the <strong>Install()</strong> method is being called in <strong>public class MvcSiteMapProviderInstaller : IWindsorInstaller</strong> as it hits a breakpoint in there.</p>
  
  <p>So what am I missing here to make this work. Remember all I am trying to do is load a SiteMap based on the logged in user on each request.</p>
  
  <p>**** UPDATE ****</p>
  
  <p>While it may not be elegant it did not require a huge amount of code as proposed by implementing a DI container. See viggity's answer (about the 4th one down) at @<a href="https://stackoverflow.com/questions/9436454/using-multiple-mvcsitemaps">Using Multiple MvcSiteMaps</a></p>