I just had to add PreservedRouteParameters="true"
[MvcSiteMapNode(Title = "Sub Title", ParentKey = "Super", PreservedRouteParameters = "id")]
public ActionResult SubAction(Guid id)
{
return View();
}
質問
Consider this setup:
public class SampleController : BaseController
{
[MvcSiteMapNode(Title = "Super Title", Key = "Super", ParentKey = "topNav")]
public ActionResult Index()
{
return View();
}
[MvcSiteMapNode(Title = "Sub Title", ParentKey = "Super")]
public ActionResult SubAction(Guid id)
{
return View();
}
}
When navigating to the SubAction the Html.MvcSiteMap().SiteMap.CurrentNode is always null. Except sometimes it works for a single Guid only (I suppose the first one requested)
Why?
Apart from this instance it works for all other actions in my project.
解決
I just had to add PreservedRouteParameters="true"
[MvcSiteMapNode(Title = "Sub Title", ParentKey = "Super", PreservedRouteParameters = "id")]
public ActionResult SubAction(Guid id)
{
return View();
}