I am trying to provide breadcrumb navigation for my application. I have 3 controllers - Project, Task & TaskDetail.
I need to show the breadcrumb something like
Projects > Project Details > Tasks > Task Details
Below is my Mvc.sitemap file
<?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="Projects" controller="Project" action="ProjectList">
<mvcSiteMapNode title="Project Details" controller="Project" action="Details"/>
</mvcSiteMapNode>
</mvcSiteMap>
my Project controller
public ActionResult ProjectList()
{
///logic to show all projects list
}
public ActionResult Details(int id)
{
///logic to show details of a project
}
this is my Task controller
public ActionResult TaskList(int projectId)
{
///logic to show all tasks of the selected project
}
public ActionResult TaskDetails(int id)
{
///logic to show details of a task
}
When I navigate to the ProjectList action method, I get the breadcrumb as
Projects
but when I navigate to Details(in project controller) I don't even see the breadcrumb
Kindly help me what am I doing wrong here.
Thanks Tarak
Looks like you have the "Project Details" mvcSiteMapNode inside of your "Projects" mvcSiteMapNode.
Change your MVC.sitemap code to this.
<?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="Projects" controller="Project" action="ProjectList"/>
<mvcSiteMapNode title="Project Details" controller="Project" action="Details"/>
</mvcSiteMap>