问题描述
我目前在 IIS7 中有 2 个 ASP.NET 3.5 Web 应用程序(我们称它们为 WebParent 和 WebChild).
I currently have 2 x ASP.NET 3.5 web applications in IIS7 (lets call them WebParent and WebChild).
WebChild 嵌套在 IIS7 中的 WebParent 列表中,并设置为应用程序(而不仅仅是 WebParent 中的虚拟目录).目前两者都使用自己的(经典)应用程序池.
WebChild is nested within the WebParent listing in IIS7 and is set up as an application (rather than just a virtual directory within WebParent). Both currently use their own (Classic) application pool.
WebParent 和 WebChild 在各自的根目录中都有自己完全定义的 web.config 文件.
Both WebParent and WebChild have their own fully defined web.config files in their own root directories.
我曾假设 WebChild 被定义为 IIS 中的应用程序",它不会从 WebParent 配置文件继承任何内容.但是,尽管进行了这种配置,但我看到与 web.config 中的各种元素相关的错误已经被定义(这是正确的,两个配置文件中都有几个项目,但我认为它们应该完全独立于一个另一个)?
I had assumed that seeing as WebChild is defined as an 'Application' within IIS, that it would not inherit anything from the WebParent configuration file. However, despite this configuration, I am seeing errors related to various elements within the web.config already being defined (which is correct, there are a couple items that are in both config files, but I thought they should be treated completely independently from one another)?
谁能解释一下为什么会发生这种情况?
Can anyone please clarify why this might be occurring?
推荐答案
如果它们重复,你必须先<remove/>
然后在子应用程序web.config中,然后添加回你想要的元素.这是假设您希望获得不同的值.如果你不这样做,那么只需省略该元素.连接字符串将是所有应用程序都可能通用的一个很好的例子 - 所以您只需在根目录中指定它.
If they are repeated, you'll have to <remove/>
then in the child application web.config first, then add back the element you'd like it it's place. This is assuming that you'd like to have a different value. If you don't, then just omit the element. A connection string would be a good example of something that is likely common for all applications - so you only need to specify it in the root.
例子:
<siteMap defaultProvider="AdminSiteMapProvider" enabled="true">
<providers>
<remove name="AdminSiteMapProvider"/>
<add name="AdminSiteMapProvider" description="Admin SiteMap provider" type="System.Web.XmlSiteMapProvider" siteMapFile="~/App_Data/admin.sitemap" securityTrimmingEnabled="true" />
</providers>
</siteMap>
这篇关于IIS 中的嵌套 ASP.NET“应用程序"继承父配置值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!