R – Why is the Sitemap.CurrentNode null

asp.net-mvcmvcsitemapprovidersitemapvb.net

System.NullReferenceException: Object reference not set to an instance of an object.

Making the Sitemap.CurrentNode work in my code is oddly a problem.

I haven't figured out how to list code on STOF yet… so here is the code that will easily be displayed.

Title: "localhost/home.aspx/about"
Response.write(SiteMap.CurrentNode.Title)

Title: localhost/Web.sitemap "
siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0"
siteMapNode url="localhost" title="ROOT" description="parent "
siteMapNode url="localhost/Home.aspx/about" title="About" description="mommy I'm cold ">
/siteMapNode
/sitemap

MVC routing is used.
routes.MapRoute("Default", "{controller}.aspx/{action}/{id}", New With {.controller = "Home", .action = "Index", .id = ""})

Thanks

Best Answer

Not every ASP.NET control works with ASP.NET MVC. You can check out this project to make it work: http://mvcsitemap.codeplex.com/

Related Topic