停止从IIS 7.5中的父ASP.NET应用程序继承web.config
我们在IIS 7.5中部署了ASP.NET网站(App 1)。然后在该应用程序下创建另一个ASP.NET应用程序(App 2)。但在应用程序2,我不希望从应用程序1.停止从IIS 7.5中的父ASP.NET应用程序继承web.config
继承web.config
如果我尝试做应用1的下面,web.config
:
<location path="." inheritInChildApplications="false">
<configSections>
<!-- etc -->
</configSections>
</location>
它报告的错误:
Config Error The configuration section 'configSections' cannot be read because it is missing a section declaration
如果我尝试这样做:
<remove name = "system.web.extensions" />
它仍然报告同样的错误:
您是否尝试过以下链接:
http://www.kowitz.net/archive/2007/05/16/stopping-asp-net-web-config-inheritance
我可以保证这是工作,我在过去做到了这一点。
谢谢。正如我所提到的,这个
无法将整个<configSections>
配置元素包装在<location path="." inheritInChildApplications="false">
中。这在ASP.NET(尚未)中不受支持。
从文档:
SectionInformation.InheritInChildApplications Property
The InheritInChildApplications property applies only to location-specific configuration settings.
另外:
Gets or sets a value that indicates whether the settings that are specified in the associated configuration section are inherited by applications that reside in a subdirectory of the relevant application.
<configSection>
元素是特殊的,并且不配置设置这样。它们用于定义配置设置的处理程序。
如果你需要从一个子应用程序中删除冲突的配置<section>
你可以在孩子应用程序的web.config
文件与<remove>
元素做到这一点:
如果你可以部署你的孩子申请到一个单独的网站(同一台机器,不同的端口),Application Request Routing可能会有帮助。
该解决方案与this post类似。首先,安装ARR。然后,在侦听非标准端口的网站上配置您的“子”应用程序。接下来,在“父”应用程序的网站上配置一个与“子”应用程序的原始路径相匹配的重写规则。有这条规则将请求转发给在新端口上侦听的新创建的网站。
我会发布一个例子,但我期望看到the post referenced above这个工作方式是非常简单的。
这是一个伟大的解决方案,像一个WordPress的虚拟目录,这是一个复杂的web.config – 2013-05-14 22:20:46
这对我有用。
对于那些无法获取位置路径解决方案的人,您可能忘记关闭位置元素标记(如果您刚刚在服务器上的文本编辑器中编辑了web.config)。这里有一个例子:
<configuration>
<configSections>
...
</configSections>
<connectionStrings>
...
</connectionStrings>
<location path="." inheritInChildApplications="false">
<system.web>
...
</system.web>
...
</location>
</configuration>
注意configSections和的ConnectionStrings不应该在这可能是有机磷农药的尝试没有成功的原因所在位置的元素。
只需要添加到上面,APP 1(父)正在使用.net 3.5框架,而APP 2(子)正在使用.net 2.x框架。 – Farrukh 2011-05-31 06:11:40
.net 3.5运行在.net 2框架的ontop上。 – 2011-06-01 10:30:00