为了构建我的网站,我选择使用Visual Studio 2010环境。 所以,我有工厂,互联网冲浪者可以从两个不同的方式去那里。 一种方法是从地图中选择地理名称,这将使他在我的目录树中的某个位置的aspx文件中。 第二种方法是从产品页面找到工厂。 在第二种方式中,我在我的代码中使用“站点地图”,并在我的web.config文件中使用相应的条目;
<siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
<providers>
<add name="XmlSiteMapProvider" description="Default SiteMap provider" type="System.Web.XmlSiteMapProvider" siteMapFile="Web.sitemap" securityTrimmingEnabled="true"/>
<add name="ProductsSiteMapProvider" description="Products SiteMap provider" type="System.Web.XmlSiteMapProvider" siteMapFile="Products.sitemap" securityTrimmingEnabled="true"/>
</providers>
在我的products.sitemap中,我正在编写以下条目;
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/pages/products.aspx" title="Products" description="Greek Olive Products">
<siteMapNode url="~/pages/products/oevoo/oevoo.aspx" title="Organic Extra Virgin Olive Oil" description="Find the Cultivation areas for this commodity" >
<siteMapNode url="~/pages/products/oevoo/agioideka.aspx" title="Flathiakes" description="Cultivation Area Flathiakes, Herakleion Crete" />
<siteMapNode url="~/pages/products/oevoo/handrinos.aspx" title="Handrinos" description="Cultivation Area Handrinos, village mountainous Messinia south-west Peloponnese " />
</siteMapNode>
<siteMapNode url="~/pages/products/evoo/evoo.aspx" title="Extra Virgin Olive Oil" description="Find the Cultivation areas for this commodity" >
<siteMapNode url="~/pages/districts/areas/agioideka.aspx" title="Flathiakes" description="Cultivation Area Flathiakes, Herakleion Crete" />
<siteMapNode url="~/pages/districts/areas/acova.aspx" title="Acova" description="Standardization factory in Argolida east Peloponnese" />
<siteMapNode url="~/pages/districts/areas/trikorfo.aspx" title="Trikorfo" description="Cultivation Area Trikorfo, mountainous area in south Peloponnese" />
<siteMapNode url="~/pages/districts/areas/handrinos.aspx" title="Handrinos" description="Cultivation Area Handrinos, village mountainous Messinia south-west Peloponnese " />
</siteMapNode>
<siteMapNode url="~/pages/products/voo/voo.aspx" title="Virgin Olive Oil" description="Find the Cultivation areas for this commodity" >
<siteMapNode url="~/pages/districts/areas/acova.aspx" title="Acova" description="Standardization factory in Argolida east Peloponnese" />
<siteMapNode url="~/pages/districts/areas/trikorfo.aspx" title="Trikorfo" description="Cultivation Area Trikorfo, mountainous Messinia south Peloponnese" />
</siteMapNode>
<siteMapNode url="~/pages/products/to/to.aspx" title="Greek Table Olives" description="Find the Cultivation areas for this commodity" >
<siteMapNode url="~/pages/districts/areas/trikorfo.aspx" title="Trikorfo" description="Cultivation Area Trikorfo, mountainous Messinia south Peloponnese" />
</siteMapNode>
</siteMapNode>
最后,当我试图(本地)运行我的网站时,它给了我以下错误;
找到了具有相同网址'/WebSite2/pages/districts/areas/acova.aspx'的多个节点。 XmlSiteMapProvider要求站点地图节点具有唯一的URL。
当然,我发现站点地图提供商不接受多个网址导致相同的位置。 我的问题是如何在products.sitemap中使用多个条目?
答案 0 :(得分:16)
是的,你可以,微软建议对网址进行一些更正,例如添加#或给出参数:
~/pages/districts/areas/acova.aspx
~/pages/districts/areas/acova.aspx#
~/pages/districts/areas/acova.aspx?id=1
是所有不同的网址,但页面相同