Mvcsitemapprovider is a menu, site map, site map path feature, and more tools for ASP. It provides the ability to configure the use of an pluggable architecture, which can be XML, a database, or dynamically generate a navigation structure.
There are three ways to implement the Sitemap in Mvcsitemapprovider: Xml,.net attributes,idynamicnodeprovider.
Below, we first implement the site map by XML.
1. Create a new MVC4 project and select an Internet application. The Mvcsitemapprovider is then installed through NuGet, and in this case Mvc4 is used, so mvcsitemapprovider Mvc4 needs to be downloaded. After the installation is successful, the Mvc.sitemap file appears.
2. The way XML is used requires configuration in the Mvc.sitemap file. The default configuration is as follows:
1 <?xml version= "1.0" encoding= "Utf-8"?> 2 <mvcsitemap xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance "3 xmlns=" http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-4.0 "4 xsi:schemalocation="/http/ mvcsitemap.codeplex.com/schemas/mvcsitemap-file-4.0 mvcsitemapschema.xsd "> 5 6 <mvcsitemapnode Title= "Home" controller= "Home" action= "Index" > 7 <mvcsitemapnode title= "about" controller= "Home" action= " About "/> 8 </mvcSiteMapNode> 9 </mvcSiteMap>
3. In the _layout.cshtml of the shared folder under the Views folder, we will place the header under <nav> under the UL comment, and then use @html.mvcsitemap (). Menu () to generate menus.
Then add @Html. Mvcsitemap () above the @renderbody (). SiteMapPath () is used to generate so-called bread crumbs.
The modified _layout.cshtml content is as follows:
4. So far, we have completed the most basic configuration, the following we look at the effect. Open the Web site and you can see the resulting menu. Click on about to see the generated breadcrumbs.
In this chapter we briefly explain the use of Mvcsitemapprovider XML to generate a sitemap, and the next one we'll delve into XML to generate the site map.
Novice Don't Spray ~
Source: >