开发者

asp.net subdirectory sitemap

开发者 https://www.devze.com 2023-03-08 00:27 出处:网络
I have this configuration in my application. ~/sitemap.aspx ~/Web.sitemap ~/mobile/sitemap.aspx ~/mobi开发者_运维问答le/Web.sitemap

I have this configuration in my application.

~/sitemap.aspx ~/Web.sitemap ~/mobile/sitemap.aspx ~/mobi开发者_运维问答le/Web.sitemap

"mobile" folder is not an application and I cannot convert it due to some reason. Thus no webconfig file is there.

What I want to do here is to use ~/mobile/Web.sitemap as the sitemap datasource for the treeview control in ~/mobile/sitemap.aspx.

When I place this code:

<asp:SiteMapDataSource runat="server" ID="MobileSiteMap" />
<asp:TreeView ID="trvSiteMap" runat="server" DataSourceID="MobileSiteMap" />

it loads ~/Web.sitemap instead of ~/mobile/Web.sitemap

Any idea?


1: Add an entry to sitemap providers in your web.config that points to your mobile sitemap.

<siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
<providers>
<clear/>
<add name="XmlSiteMapProvider" type="System.Web.XmlSiteMapProvider" siteMapFile="Web.siteMap"/>
<add name="MyMobileSiteMapProvider" type="System.Web.XmlSiteMapProvider" siteMapFile="~/mobile/Web.sitemap"/>
</providers>
</siteMap>

2: Set the SiteMapProvider property of your MobileSiteMap DataSource to this newly added sitemap.

<asp:SiteMapDataSource runat="server" ID="MobileSiteMap"  SiteMapProvider="MyMobileSiteMapProvider" />
<asp:TreeView ID="trvSiteMap" runat="server" DataSourceID="MobileSiteMap" />
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号