This question is locked. New answers and comments are not allowed.
I am getting the following error in my _Layout.cshtml file on the BindTo method when trying to bind to a sitemap file. It is an MVC 3 project with Razor.
"You must have SiteMap defined with key "YeagerTech" in ViewData dictionary."
"You must have SiteMap defined with key "YeagerTech" in ViewData dictionary."
@(Html.Telerik().Menu() .Name("menu") .BindTo("YeagerTech"));
I have a Sitemap file set up named "YeagerTech.sitemap". In it, I have the following xml:<?xml version="1.0" encoding="utf-8" ?> <sitemap> <siteMapNode title="Home" controller="Home" action="Index"> <siteMapNode title="Home"> <siteMapNode controller="Home" action="Testimonials" title="Testimonials" /> <siteMapNode controller="Home" action="About" title="Contact Us" /> <siteMapNode controller="Home" action="Payment" title="Make a Payment" /> </siteMapNode> <siteMapNode title="Customer"> <siteMapNode controller="Customer" action="Index" title="Customer Info" /> </siteMapNode> <siteMapNode title="Sitemap"> <siteMapNode controller="Home" action="Sitemap" title="Sitemap" /> </siteMapNode> </siteMapNode> </sitemap>
I have a MenuController set up in my Controllers folder with the following code:using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Telerik.Web.Mvc;namespace YeagerTech.Controllers
{
public partial class MenuController : Controller
{
[PopulateSiteMap(SiteMapName = "YeagerTech", ViewDataKey = "YeagerTech")]
public ActionResult SiteMapBinding()
{
if (!SiteMapManager.SiteMaps.ContainsKey("YeagerTech"))
{
SiteMapManager.SiteMaps.Register<XmlSiteMap>("YeagerTech", sitmap => sitmap.LoadFrom("~/YeagerTech.sitemap"));
}return View();
}
}
}
The project compiles fine. It's just when I try to run it.
I followed the example at the following link:
http://demos.telerik.com/aspnet-mvc/razor/menu/sitemapbinding
It's not getting into the MenuController obviously, because my HomeController is the default controller. Where do I need to place the code that
exists in my MenuController?
Do I need to put this code on every method in every controller?