Asp.net 多个站点地图的使用
如何设计时实现呢?
假设我们站点下有2个sitemap文件:web1.sitemap , web2.sitemap
在web.config里如下设定:
description="SiteMap provider which reads in .sitemap XML files."
type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
siteMapFile="web1.sitemap"
securityTrimmingEnabled="true"/>
description="SiteMap provider which reads in .sitemap XML files."
type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
siteMapFile="web2.sitemap"
securityTrimmingEnabled="true"/>
设计时,在SiteMapDataSource1属性窗口的SiteMapProvider 里填 web2 即可
Asp.net 一个站点地图的使用
站点地图文件:
Web.sitemap
xml version = "1.0 " encoding = "utf-8 "?>
< siteMap xmlns = "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0 ">
< siteMapNode url = "default.aspx " title = " 首页 " description = "">
< siteMapNode url = "Supply.aspx " title = " 产品信息 " description = "" >
< siteMapNode url = "productdetails.aspx " title = " 产品详细信息 " description = "" />
siteMapNode >
< siteMapNode url = "register.aspx " title = " 新用户注册 "/>
< siteMapNode url = "Demand.aspx " title = " 产品信息 " description = "">
siteMapNode >
< siteMapNode url = "Projects.aspx " title = " 招投标信息 " description = "">
< siteMapNode url = "DownLoad.aspx " title = " 相关表格下载 " description = "" />
< siteMapNode url = "ProjectInfor.aspx " title = " 招投标详细信息 " description = "" />
siteMapNode >
< siteMapNode url = "newsfront.aspx " title = " 新闻 " description = "">
< siteMapNode url = "news_detail.aspx " title = " 行业资讯详细信息 " description = "" />
< siteMapNode url = "company_details.aspx " title = " 会员展厅详细信息 " description = "" />
< siteMapNode url = "ManuscriptFront.aspx " title = " 在线投稿 " description = "" />
< siteMapNode url = "subject_detail.aspx " title = " 专题栏目详细信息 " description = "" />
< siteMapNode url = "expertinterview_detail.aspx " title = " 人物专访详细信息 " description = "" />
siteMapNode >
< siteMapNode url = "ForeTrain.aspx " title = " 培训咨询 " description = "">
< siteMapNode url = "TrainInfor.aspx " title = " 培训详细信息 " description = "" />
< siteMapNode url = "BusiHandBook.aspx " title = " 商务手册 " description = "" />
< siteMapNode url = "Technology.aspx " title = " 技术咨询 " description = "">
< siteMapNode url = "TechInfor.aspx " title = " 技术信息 " description = ""/>
siteMapNode >
< siteMapNode url = "Expert.aspx " title = " 专家顾问团 " description = "" />
siteMapNode >
< siteMapNode url = "ExhibitFront.aspx " title = " 机电信息展览馆 " description = "">
< siteMapNode url = "exhibit_detail.aspx " title = " 会展详细信息 " description = ""/>
siteMapNode >
siteMapNode >
siteMap >
Web.config 配置
< siteMap defaultProvider = "XmlSiteMapProvider " enabled = "true ">
< providers >
< add name = "XmlSiteMapProvider "
description = "SiteMap provider which reads in .sitemap XML files. "
type = "System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a "
siteMapFile = "web.sitemap "/>
providers >
siteMap >
前台代码:
< asp : TreeView ID ="TreeView1" runat ="server" DataSourceID ="SiteMapDataSource1">
asp : TreeView >
div >
< asp : SiteMapDataSource ID ="SiteMapDataSource1" runat ="server" SiteMapProvider ="XmlSiteMapProvider " />