我想添加地圖在我的項目,但我仍然有錯誤Asp.Net的mvc 4地圖
Not all configured nodes could be paired with a parent node. Check your parent keys to ensure that a node with a corresponding key exists in the SiteMap. Note that the match is case sensitive.
這裏是我的網站地圖
<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMap xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-4.0"
xsi:schemaLocation="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-4.0 MvcSiteMapSchema.xsd">
<mvcSiteMapNode title="Home" controller="Home" action="Index" key="Home">
<mvcSiteMapNode title="Quiz" controller="Quiz" action="Index" key="Quiz" dynamicNodeProvider="SiteMapExample.Models.DynamicNodeCategory,SiteMapExample" >
</mvcSiteMapNode>
</mvcSiteMapNode>
</mvcSiteMap>
,這裏是我的模型,生成動態節點地圖
public class DynamicNodeCategory : DynamicNodeProviderBase
{
public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
{
string[]category={".Net","Java","C"};
for (int i = 0; i < 3; i++)
{
DynamicNode dNode = new DynamicNode();
dNode.ParentKey = "Quiz";
dNode.Title = category[i];
dNode.Action = "Test";
dNode.Controller = "Quiz";
dNode.Key = dNode.Title;
dNode.RouteValues.Add("category", dNode.Title);
yield return dNode;
}
}
}
,我使用站點地圖在這裏
@Html.MvcSiteMap().SiteMapPath()
thnx爲答案先生,但我使用此屬性動態節點提供程序'[MvcSiteMapNodeAttribute(DynamicNodeProvider =「SiteMapExample.Models.DynamicNodeCategory,SiteMapExample」)]' –
@AbhishekSingh - 我更新了我的答案。 – NightOwl888