停止从 IIS 7.5 中的父 ASP.NET 应用程序继承 web.config

发布于 2024-11-10 17:57:47 字数 600 浏览 2 评论 0原文

我们在 IIS 7.5 中部署了 ASP.NET 网站(应用程序 1)。然后在该应用程序下创建另一个 ASP.NET 应用程序(应用程序 2)。但在应用程序 2 中,我不想从应用程序 1 继承 web.config

如果我尝试在应用程序 1 的 web.config 中执行以下操作

<location path="." inheritInChildApplications="false"> 
    <configSections> 

    <!-- etc -->

    </configSections>
</location>

:报告错误:

配置错误 配置部分“configSections”无法 阅读,因为它缺少一个部分 声明

如果我尝试这样做:

<remove name = "system.web.extensions" /> 

它仍然报告相同的错误:

We have deployed an ASP.NET Website (App 1) in IIS 7.5. Then under that application create another ASP.NET application (App 2). But in App 2, I don't want to inherit the web.config from App 1.

If I try to do the following in App 1's, web.config:

<location path="." inheritInChildApplications="false"> 
    <configSections> 

    <!-- etc -->

    </configSections>
</location>

it reports the error:

Config Error The configuration section 'configSections' cannot be
read because it is missing a section
declaration

If I try to do:

<remove name = "system.web.extensions" /> 

it still reports the same error:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

夏有森光若流苏 2024-11-17 17:57:47

如果您可以将子应用程序部署到单独的网站(同一计算机,不同端口),

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

我会发布一个示例,但我希望通过查看 上面引用的帖子

If you can deploy your child application to a separate website (same machine, different port), Application Request Routing may be able to help with this.

The solution is similar to this post. First, install ARR. Then, configure your "child" application on a website that listens on a non-standard port. Next, configure a rewrite rule on the "parent" application's web site that matches the original path to the "child" application. Have this rule forward the request to the newly created website listening on the new port.

I would post an example, but I expect it is fairly straightforward to see how this would work by looking at the post referenced above.

向日葵 2024-11-17 17:57:47

这对我有用。

对于那些无法使位置路径解决方案正常工作的人,您可能忘记关闭位置元素标签(如果您刚刚在服务器上的文本编辑器中编辑了 web.config)。下面是一个示例:

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

请注意,configSections 和 connectionStrings 不应位于 location 元素中,这可能是 OP 尝试不起作用的原因。

This worked for me.

For those who could not get the location path solution working you might have forgotten to close the location elements tag (if you just edited the web.config in a text editor on the server). Here is an example:

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

Notice that configSections and connectionStrings should not be in the location element which is probably the reason the OPs attempt did not work.

不弃不离 2024-11-17 17:57:47

您是否尝试过以下链接:

http: //www.kowitz.net/archive/2007/05/16/stopping-asp-net-web-config-inheritance

我可以保证这个工作正常,就像我在 过去的。

Have you tried the following link:

http://www.kowitz.net/archive/2007/05/16/stopping-asp-net-web-config-inheritance

I can vouch for this as working as I have done this in the past.

记忆里有你的影子 2024-11-17 17:57:47

您无法将整个 配置元素包装在 。 ASP.NET 尚不支持此功能。

从文档中:

SectionInformation.InheritInChildApplications 属性

InheritInChildApplications
属性仅适用于
特定于位置的配置
设置。

还:

获取或设置一个值,该值指示
是否是设置
在关联的配置部分中指定被继承
通过驻留在
相关子目录
应用程序。

元素很特殊,本身并不是配置设置。它们用于定义配置设置的处理程序。

如果您需要从子应用程序中删除冲突的配置

,您可以在子应用程序的 web.config 文件中使用 执行此操作; 元素:

删除 configSections 元素(常规设置架构)

You can't wrap the whole <configSections> configuration element in a <location path="." inheritInChildApplications="false">. This isn't supported in ASP.NET (yet).

From the documentation:

SectionInformation.InheritInChildApplications Property

The InheritInChildApplications
property applies only to
location-specific configuration
settings.

Also:

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> elements are special and are not configuration settings as such. They are used to define the handlers for configuration settings.

If you need to remove a conflicting configuration <section> from a child application you can do this in the child application's web.config file with the <remove> element:

remove Element for configSections (General Settings Schema)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文