You must have SiteMap defined with key "MvcSiteMapProvider" in ViewData dictionary.

Jul 28, 2011 at 6:39 PM

I have looked over the web at this specific issue and seems to be pointing back to here...

I am using MVC3 with VisualStudio 2010 and the Telerik MVC extensions. I am also using the lateste stable version of the MVC Site Map Provider from CodePlex.

I cannot create a menu control from the above objects...

I am simply trying to use the MvcSiteMapProvider with the Telerik menu control. What am I doing wrong in the code? How can I accomplish this?

I have my code set up as the following. Notice boldfaced lines...

  • Global.asax.cs
  • protected void Application_Start()
            {
                AreaRegistration.RegisterAllAreas();
     
                XmlSiteMapController.RegisterRoutes(RouteTable.Routes); // register sitemap for search engine indexing
     
                RegisterGlobalFilters(GlobalFilters.Filters);
                RegisterRoutes(RouteTable.Routes);
                //RegisterModelBinders(ModelBinders.Binders);
            }
 
  • Mvc.sitemap file on root of project
  • <?xml version="1.0" encoding="utf-8" ?>
    <mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-3.0" enableLocalization="true">
      <mvcSiteMapNode title="Home" controller="Home" action="Index" changeFrequency="Always" updatePriority="Normal">
        <mvcSiteMapNode title="Testimonials" controller="Home" action="Testimonials" />
        <mvcSiteMapNode title="Customer Info" controller="Customer" action="Index" />
        <mvcSiteMapNode title="Contact Us" controller="Home" action="About" />
        <mvcSiteMapNode title="Make a Payment" controller="Home" action="Payment" />
        <mvcSiteMapNode title="Sitemap" controller="Home" action="Sitemap" />
      </mvcSiteMapNode>
    </mvcSiteMap>

  • Views/Shared/_Layout.cshtml
  • <!DOCTYPE html>
    <html>
    <head>
        <title>@ViewBag.Title</title>
        <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
        <script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
        @(Html.Telerik().StyleSheetRegistrar().DefaultGroup(group => group.Add("telerik.common.css").Add("telerik.windows7.css").Combined(true).Compress(true)))</head>
    <body>
        <div class="page">
            <div id="header">
                <div id="title">
                    <h1>
                        YeagerTech Consulting, Inc.</h1>
                    <h2>
                        The Trusted Source for Quality Microsoft ASP.Net Projects</h2>
                </div>
                <div id="logindisplay">
                    @Html.Partial("_LogOnPartial")
                </div>
                @*@(Html.Telerik().Menu()
                        .Name("menu")
                        .Items(menu => {
                            menu.Add().Text("Home").Action("Index", "Home");
                            menu.Add().Text("Testimonials").Action("Testimonials", "Home");
                            menu.Add().Text("Customer").Action("Index", "Customer");
                            menu.Add().Text("Contact Us").Action("About", "Home");
                            menu.Add().Text("Make a Payment").Action("Payment", "Home");
                            //menu.Add().Text("Sitemap").Action("Sitemap", "Home");
                        }))*@ 
                        
                 @(Html.Telerik().Menu()
                        .Name("menu")
                        .BindTo("MvcSiteMapProvider"));
                        
            </div>
            <div id="main">
                @RenderBody()
                <div id="footer">
                </div>
            </div>
        </div>
        @(Html.Telerik().ScriptRegistrar().DefaultGroup(group => group.Combined(true).Compress(true)))</body>
    </html>
    
Coordinator
Aug 26, 2011 at 12:33 PM

Not sure, but the Telerik menu doesn't use ASP.NET sitemaps but their own implementation. See http://demos.telerik.com/aspnet-mvc/menu/sitemapbinding