停止从 IIS 7.5 中的父 ASP.NET 应用程序继承 web.config
我们在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您可以将子应用程序部署到单独的网站(同一计算机,不同端口),
该解决方案类似于 这篇文章。首先,安装 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.
这对我有用。
对于那些无法使位置路径解决方案正常工作的人,您可能忘记关闭位置元素标签(如果您刚刚在服务器上的文本编辑器中编辑了 web.config)。下面是一个示例:
请注意,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:
Notice that configSections and connectionStrings should not be in the location element which is probably the reason the OPs attempt did not work.
您是否尝试过以下链接:
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.
您无法将整个。 ASP.NET 尚不支持此功能。
配置元素包装在从文档中:
还:
元素很特殊,本身并不是配置设置。它们用于定义配置设置的处理程序。如果您需要从子应用程序中删除冲突的配置
,您可以在子应用程序的
web.config
文件中使用执行此操作;
元素: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:
Also:
<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'sweb.config
file with the<remove>
element: