简体   繁体   中英

Asp.net Web.config - Moving the sitemap provider outside the web.config

We can move our connectionStrings to a separate file ie:

<connectionStrings configSource="ConnectionStrings.config"/>  

It would be useful to move the sitemap section outside of web.config

<siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
<providers>
.... add ther providers here name here....
</providers>
</siteMap>

I currently add an <add name="" ..... /> inside the <providers> section and add a sitemap to the site.

A site with many pages with diverse menus benefit from many sitemaps.

I would like to add them without having to update the web.config. (IE put and add in this section in its own code and add the new sitemap.)

vs2008 intellisense does show configSource as valid, but I have not been able to get this to work.

Is it allowed implemented in web.config? If so an example of working code would be appreciated.

I'm not sure about adding the sitemap information to the web.config, but it does look like you can use multiple sitemap files. The default sitemap file is web.sitemap and then you can add any number of child sitemap files.

See this link:

http://msdn.microsoft.com/en-us/library/ms178426(v=VS.90).aspx

I have it working: The Web.config now has a line:

<siteMap configSource="MySiteMaps.config" />

And I now have a file Called MySiteMaps.config containing:

 <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
  <providers>
       <add name="XmlName1" description="desc1" etc.../>
       <add name="XmlName2" description="desc2" etc.../>
  </providers>
 </sitemap>

Works just fine.

The only issue for me is the little blue line under the siteMap element in the MySiteMaps.config file. "The 'siteMap' element is not declaired." Hope this helps!

I am researching the blue squigly line. I could live with it, but I don't like loose ends.

Mike

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM