I have been going insane trying to figure out why I can't get the ASP.NET MVCSiteMap to work.
I have downloaded the latest version from CodePlex (version 2.3) and set up the references as outlined on CodePlex. I downloaded the DisplayTemplates and set up a basic Mvc.sitemap file:
<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-2.0" enableLocalization="true">
<mvcSiteMapNode title="Dashboard" controller="Admin" action="Index" changeFrequency="Always" updatePriority="Normal">
<mvcSiteMapNode title="Users" controller="Users" action="Index" />
<mvcSiteMapNode title="Reports" controller="Reports" action="Index" />
</mvcSiteMapNode>
</mvcSiteMap>
When using the HTML Helper to generate a basic menu, I get a blank output:
<%: Html.MvcSiteMap().Menu() %>
In the MenuHelperModel.ascx DisplayTemplate, I am outputting the number of nodes:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl`1[ [MvcSiteMapProvider.Web.Html.Models.MenuHelperModel,MvcSiteMapProvider] ]" %>
<%@ Import Namespace="System.Web.Mvc.Html" %>
<%@ Import Namespace="MvcSiteMapProvider.Web.Html.Models" %>
<%: Model.Nodes.Count %>
<ul>
<% foreach (var node in Model.Nodes) { %>
<li><%=Html.DisplayFor(m => node)%>
<% if (node.Children.Any()) { %>
<%=Html.DisplayFor(m => node.Children)%>
<% } %>
</li>
<% } %>
</ul>
The resulting output is:
0
I cannot figure out what I am doing wrong. I don't get any errors, and I am using the Mvc.sitemap file provided by the CodePlex project site with some minor modifications for my actions/controllers.
NOTE: I have also downloaded the sample project, but it will not compile for me and the sitemap file being used is way too complicated for me to figure out at this early stage in my understanding of how to use this.
Any help is greatly appreciated.