Asp.net sitemap

Source: Internet
Author: User

First, create the sitemap file, right-click project-> add new item, and Select site map in the pop-up box. Then, select OK. Now the sitemap file is created.

Edit its content. The default content in the new sitemap file is as follows:

<? Xml version = "1.0" encoding = "UTF-8"?>
<Sitemap xmlns = "http://schemas.microsoft.com/asp tutorial net/sitemap-file-1.042622>
<Sitemapnode url = "" title = "" description = ">
<Sitemapnode url = "" title = "" description = "/>
<Sitemapnode url = "" title = "" description = "/>
</Sitemapnode>
</Sitemap>


<Sitemapnode> attributes:

Url-link address
Title-displayed title
Description-description (tooltip)
Resourcekey-used for localization (enablelocalization = true must be added to the <sitemap> node)
Securitytrimmingenabled-whether to enable sitemap to support security features
Roles-which roles can access the current node and multiple roles are separated by commas (you need to set securitytrimmingenabled to true)
Sitemapfile-reference another sitemap file
Note: When the application permission is applied, the provider of the sitemap node in web. config must also have the corresponding configuration (securitytrimmingenabled = "true ")

Example:

<Sitemapnode url = "" title = "" description = "" roles = "administrator, manager, normaluser">
<Sitemapnode url = "~ /Admin/manageuser/manage_users.aspx "title =" manage users "description =" "roles =" administrator "/>
<Sitemapnode url = "~ /Admin/manage info/manage_mirrors.aspx "title =" manage hotels "description =" "roles =" manager "/>
<Sitemapnode url = "~ /Admin/regioninfo/region_list.aspx "title =" manage regions "description =" "roles =" administrator "/>
<Sitemapnode url = "~ /Admin/managetable/manage_selfdetails.aspx "title =" manage tables "description =" "roles =" normaluser "/>

Here, you need to set the roles, which can be set in web. config under each directory.

Configure sitemap in web. config,

<Sitemap defaultprovider = "sitemapprovider">
<Providers>
<Add name = "sitemapprovider"
Type = "system. web. xmlsitemapprovider"
Securitytrimmingenabled = "true"
Sitemapfile = "web. sitemap"/>
</Providers>
</Sitemap>

Finally, apply sitemap in masterpage,

<Asp: menu id = "menu1" runat = "server" performanceid = "sitemapdatasourcedefault" orientation = "horizontal">
<Staticmenuitemstyle forecolor = "white" itemspacing = "10px" font-underline = "false"/>
<Staticselectedstyle forecolor = "#99 ffff"/>
<Dynamicselectedstyle forecolor = "#99 ffff"/>
</Asp: menu>
<Asp: sitemapdatasource id = "sitemapdatasourcedefault" runat = "server" sitemapprovider = "sitemapprovider" showstartingnode = "false"/>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.