MVCSitemap节点不渲染

时间:2011-04-22 21:39:00

标签: asp.net-mvc-3 mvcsitemapprovider

我已经安装了MvcSiteMap提供程序,并且基本的站点地图定义如下:

<?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">
<mvcSiteMapNode title="About" controller="Home" action="About"/>
<mvcSiteMapNode title="Contact" controller="Home" action="Contact"/>
</mvcSiteMapNode>
<mvcSiteMapNode title="Borrower" controller="Borrower" action="Index">
<mvcSiteMapNode title="Sign Up" controller="Borrower" action="Create"/>
</mvcSiteMapNode>
<mvcSiteMapNode title="Investor" controller="Investor" action="Index">
<mvcSiteMapNode title="Sign Up" controller="Investor" action="Create"/>
</mvcSiteMapNode>
<mvcSiteMapNode title="Dealer" controller="Dealer" action="Index">  
<mvcSiteMapNode title="Sign Up" controller="Dealer" action="Create"/>
</mvcSiteMapNode>
</mvcSiteMap>

我的HomeController:     使用系统;     使用System.Collections.Generic;     使用System.Linq;
    使用System.Web;     使用System.Web.Mvc;     使用Veehco.Models;     使用Telerik.Web.Mvc;

namespace Veehco.Controllers
{
public class HomeController : Controller
{
    VeehcoEntities _db;

    public HomeController()
    {
        _db = new VeehcoEntities();
    }

    public ActionResult Index()
    {
        ViewBag.Message = "Welcome to Veehco!";

        return View();
    }

    public ActionResult About()
    {
        return View();
    }

    public ActionResult Contact()
    {
        return View();
    }

    public ActionResult MenuPartial()
    {
        return PartialView("~/Shared/MenuPartial");
    }   
}

public partial class MenuController : Controller
{
    [PopulateSiteMap(SiteMapName = "Veehco", ViewDataKey = "Veehco")]

    public ActionResult SiteMapBinding()
    {
        if (!SiteMapManager.SiteMaps.ContainsKey("Veehco"))
        {
            SiteMapManager.SiteMaps.Register<XmlSiteMap>("Veehco", sitemap => sitemap.LoadFrom("~/Veehco.sitemap"));
        }
        return View();
    }

    public ActionResult Orientation(string orientation) 
    { 
        ViewData["orientation"] = orientation ?? "Horizontal"; 
        return View(); 
    }

    public ActionResult AnimationEffects(string animation, bool? enableOpacityAnimation, int? openDuration, int? closeDuration)
    { 
        ViewData["animation"] = animation ?? "slide"; 
        ViewData["enableOpacityAnimation"] = enableOpacityAnimation ?? true; 
        ViewData["openDuration"] = openDuration ?? 200; ViewData["closeDuration"] = closeDuration ?? 200; 
        return View(); 
    }
}
}

当我构建并查看此站点时,只有“关于”和“联系”链接可见。如何设置我的站点地图和/或HomeController以显示其他顶级和子节点?

Thansk很多!!

1 个答案:

答案 0 :(得分:5)

我相信您只想在mvcSiteMapNode的根目录中放置一个mvcSiteMap元素。尝试将借款人,投资者和经销商纳入您的主页元素(与关于和联系相同的级别)。