AAlferez
AAlferez

Reputation: 1502

MVC Site Map Provider ConfigurationErrorException: The site map file is invalid

I reduced the sitemap to see where the problem is and even that way I can't.

<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-3.0"
        enableLocalization="true">
  <mvcSiteMapNode key="0" title="BPM" controller="OEE" action="StationCycleTime">
    <mvcSiteMapNode key="1" title="LiveOEE" controller="OEE" action="LiveOEE">
    </mvcSiteMapNode>
  </mvcSiteMapNode>
</mvcSiteMap>

In my view:

@Html.DevExpress().Menu(
settings =>
{
    settings.Name = "Mvc";
    settings.AllowSelectItem = true;
    settings.EncodeHtml = false;
    settings.Orientation = System.Web.UI.WebControls.Orientation.Horizontal;
    settings.Width = 100;
}).BindToSiteMap("~/Mvc.sitemap", false).GetHtml()

I tried without the key attribute, putting url instead of controller and action, nothing works.

Some ideas please

Upvotes: 0

Views: 615

Answers (1)

OzrenTkalcecKrznaric
OzrenTkalcecKrznaric

Reputation: 5646

The way I see it, DevExpress doesn't support MVC SiteMap provider implementation. You can use plain old sitemap instead. If you're comfortable with that, bind your DevExpress menu to SiteMap file:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
  <siteMapNode title="BPM" url="OEE/StationCycleTime">
    <siteMapNode title="LiveOEE" url="OEE/LiveOEE" />
  </siteMapNode>
</mvcSiteMap>

It leaves you without the extended functionality that MVC implementation offers :(

However, you can make some use of menu (MenuSettings) event ItemDataBound property and attach your own (e.g. anonymous) handler to capture default binding. And then add your own custom attribute handling:

@Html.DevExpress().Menu(
settings =>
{
    settings.Name = "Mvc";
    settings.AllowSelectItem = true;
    settings.EncodeHtml = false;
    settings.Orientation = System.Web.UI.WebControls.Orientation.Horizontal;
    settings.Width = 100;
    settings.ItemDataBound = (sender, e) =>
    {
        var node = e.Item.DataItem as SiteMapNode;

        if (node != null)
        {
            if (!string.IsNullOrEmpty(node["key"]))
            {
                // Do something with your lookup key
            }
        }
     };
}).BindToSiteMap("~/Mvc.sitemap", false).GetHtml()

Upvotes: 1

Related Questions