简体   繁体   English

Asp.net Web.config-将站点地图提供程序移到web.config之外

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

We can move our connectionStrings to a separate file ie: 我们可以将connectionStrings移到一个单独的文件,即:

<connectionStrings configSource="ConnectionStrings.config"/>  

It would be useful to move the sitemap section outside of web.config 将sitemap部分移到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. 目前,我在<providers>部分内添加了<add name="" ..... />并将站点地图添加到该站点。

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. 我想添加它们,而不必更新web.config。 (IE put and add in this section in its own code and add the new sitemap.) (IE在此部分以自己的代码添加并添加了新站点地图。)

vs2008 intellisense does show configSource as valid, but I have not been able to get this to work. vs2008 intellisense确实显示configSource为有效,但我无法使其正常工作。

Is it allowed implemented in web.config? 是否允许在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. 我不确定要将站点地图信息添加到web.config中,但看起来确实可以使用多个站点地图文件。 The default sitemap file is web.sitemap and then you can add any number of child sitemap files. 默认站点地图文件为web.sitemap,然后您可以添加任意数量的子站点地图文件。

See this link: 看到这个链接:

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

I have it working: The Web.config now has a line: 我正在工作:Web.config现在有一行:

<siteMap configSource="MySiteMaps.config" />

And I now have a file Called MySiteMaps.config containing: 现在,我有一个名为MySiteMaps.config的文件,其中包含:

 <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. 对我而言,唯一的问题是MySiteMaps.config文件中siteMap元素下方的蓝线。 "The 'siteMap' element is not declaired." “'siteMap'元素未声明。” Hope this helps! 希望这可以帮助!

I am researching the blue squigly line. 我正在研究弯曲的蓝色线条。 I could live with it, but I don't like loose ends. 我可以忍受,但我不喜欢松散的结局。

Mike 麦克风

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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