Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I use ASP.Net2 Navigation sitemap in subsite 1

Status
Not open for further replies.

AndyH1

Programmer
Jan 11, 2004
350
GB
I'm currently working on a small subdirectory site for my company on a larger website site.

I have a subdirectory /mycompany/ on a main site ie where site is the main site and mycompany is my subfolder. where my pages will be based and these use the masterpages of the main site (which I cannot alter), however I want to add a navigation menu panel on the left on my pages in one of the content fields which only refers to my area

ie /company/About Us
/Company/Calender
etc

just those pages in my subdirectory

I wanted to use the new navigation menu of asp.net2 using the code

<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server"></asp:SiteMapDataSource>
<asp:Menu runat="server" DataSourceID="SiteMapDataSource1"></asp:Menu>

This seems to work fine if I put the web.sitemap in the top of the main site, but I really need it to use a sitemap file in my subfolder. Is there anyway I can tell the SiteMapDataSource to get the sitemap file from within my subfolder 'mycompany' (possibly with a different name ie company.sitemap) rather than the default location and name (~/web.sitemap)?

Thanks
Andy
 
In your web.config file you can set multiple sitemap files e.g.
Code:
<siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
      <providers>
        <add siteMapFile="web.sitemap" name="XmlSiteMapProvider" type="System.Web.XmlSiteMapProvider" securityTrimmingEnabled="true"/>
        <add siteMapFile="my.sitemap" name="MyXmlSiteMapProvider" type="System.Web.XmlSiteMapProvider" securityTrimmingEnabled="true"/>
      </providers>
    </siteMap>
Then, in your SiteMapDataSource set the relevant SiteMapProvider e.g.
Code:
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" SiteMapProvider="MyXmlSiteMapProvider" />


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Thanks, however I'm not sure I'll be allowed to change/add to the web.config of the main site.

Thanks for the advise though
Andy
 
Didn't think I could make another web.config. The subfolder isn't a virtual directory in IIS so assumed there could only be one web.config (in the main directory) on the site.
Thanks
Andy

 
I created a web.config in the mycompany folder and put
<configuration>
<system.web>
<siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
<providers>
<add siteMapFile="web.sitemap" name="XmlSiteMapProvider" type="System.Web.XmlSiteMapProvider" securityTrimmingEnabled="true"/>
<add siteMapFile="~/mycompany/mycompany.sitemap" name="MyCompanyXmlSiteMapProvider" type="System.Web.XmlSiteMapProvider" securityTrimmingEnabled="true"/>
</providers>
</siteMap>
</system.web>
</configuration>

in it
but I get the error

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

Source Error:


Line 2:
Line 3: <system.web>
Line 4: <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
Line 5: <providers>
Line 6: <add siteMapFile="web.sitemap" name="XmlSiteMapProvider" type="System.Web.XmlSiteMapProvider" securityTrimmingEnabled="true"/>

Any idea what I'm doing wrong?

 
>This error can be caused by a virtual directory not being >configured as an application in IIS.
>Have you done this?

The problem is I don't have access to the rest of the site just the mycompany folder. But the folder has not been set up as a virtual directory its just a normal subfolder of the site.

Thanks
Andy
 
Thanks for all your help ca8msm. Have it working now
Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top