Anyone have an example of how to create a breadcrumb trail using the latest MVC3 r开发者_如何转开发elease and razor syntax?
You should be able to achieve this by using the MVC SiteMap Provider: http://mvcsitemap.codeplex.com/. It contains features to create breadcrumb trails, and is documented fairly well (and you can always grab the code and modify it to do exactly what you want.)
To get the MvcSitemapProvider working do the following:
In your .sitemap
file change:
<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-2.0" />
to:
<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-3.0" />
I ended up writing my own simple sitemap provider. It's just based on URLs just like the ASP.NET standard sitemap. It works because the site is really simple but has lots of static files.
Check out the Mesoboard project's source code in ASP.NET MVC3 w/Razor:
http://mesoboard.codeplex.com/
The project implements a breadcrum mechanism among other things.
精彩评论