2011-05-31 128 views
10

我们在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" /> 

它仍然报告同样的错误:

+0

只需要添加到上面,APP 1(父)正在使用.net 3.5框架,而APP 2(子)正在使用.net 2.x框架。 – Farrukh 2011-05-31 06:11:40

+0

.net 3.5运行在.net 2框架的ontop上。 – 2011-06-01 10:30:00

回答

0

无法将整个<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>元素做到这一点:

remove Element for configSections (General Settings Schema)

+1

其实我们可以删除单个项目,如 但我们不能删除“Sectiongroup”这样的。 。这是行不通的,这是主要问题。 – Farrukh 2011-06-02 13:14:30

+0

@farrukh - 你可以发表一个你如何使用它的例子。 – Kev 2011-06-02 14:27:33

7

如果你可以部署你的孩子申请到一个单独的网站(同一台机器,不同的端口),Application Request Routing可能会有帮助。

该解决方案与this post类似。首先,安装ARR。然后,在侦听非标准端口的网站上配置您的“子”应用程序。接下来,在“父”应用程序的网站上配置一个与“子”应用程序的原始路径相匹配的重写规则。有这条规则将请求转发给在新端口上侦听的新创建的网站。

我会发布一个例子,但我期望看到the post referenced above这个工作方式是非常简单的。

+0

这是一个伟大的解决方案,像一个WordPress的虚拟目录,这是一个复杂的web.config – 2013-05-14 22:20:46

4

这对我有用。

对于那些无法获取位置路径解决方案的人,您可能忘记关闭位置元素标记(如果您刚刚在服务器上的文本编辑器中编辑了web.config)。这里有一个例子:

<configuration> 
    <configSections> 
... 
    </configSections> 
    <connectionStrings> 
... 
    </connectionStrings> 
    <location path="." inheritInChildApplications="false"> 
    <system.web> 
... 
    </system.web> 
... 
    </location> 
</configuration> 

注意configSections和的ConnectionStrings不应该在这可能是有机磷农药的尝试没有成功的原因所在位置的元素。

相关问题