web.config继承:>导致中出现 XML 解析错误
我正在尝试将一个小型 asp.net 应用程序添加到现有网站的子文件夹中。问题是根 web.config 文件包含破坏我的应用程序的模块。我想阻止/删除 Web.config 继承。
父 web.config
...
<system.webServer>
...
<modules>
<add name="WwwSubDomainModule" type="BlogEngine.Core.Web.HttpModules.WwwSubDomainModule, BlogEngine.Core" />
<add name="UrlRewrite" type="BlogEngine.Core.Web.HttpModules.UrlRewrite, BlogEngine.Core" />
...
</modules>
...
我无法在根目录中使用以下位置标记,因为我确实想要继承其他子文件夹。有什么办法可以让孩子关闭对父母的继承吗?
<location path="." inheritInChildApplication="false">
子 web.config
...
<system.webServer>
...
<modules>
<clear/>
</modules>
...
我尝试使用clear,但这会导致一个奇怪的解析错误: “XML 解析错误:找不到元素位置:...第 1 行,第 1 列:”
如果我对每个模块使用删除,我会取得一些成功。只要我至少留下1个模块。 (无论哪个)当我删除最后一个模块时,我得到与清除相同的解析错误。任何人都知道为什么会发生这个错误?还有其他方法可以消除 web.config 继承吗?
I am trying to add a small asp.net application to a sub folder of my existing website. The issue is that the root web.config file contains modules that break my application. I want to prevent/remove the Web.config inheritance.
Parent web.config
...
<system.webServer>
...
<modules>
<add name="WwwSubDomainModule" type="BlogEngine.Core.Web.HttpModules.WwwSubDomainModule, BlogEngine.Core" />
<add name="UrlRewrite" type="BlogEngine.Core.Web.HttpModules.UrlRewrite, BlogEngine.Core" />
...
</modules>
...
I can't use the following location tag in the root because there are other sub folders where I do want to inherit. Is there any way for the child to turn off inheritance from the parent?
<location path="." inheritInChildApplication="false">
Child web.config
...
<system.webServer>
...
<modules>
<clear/>
</modules>
...
I tried using clear but this results in a strange parsing error:
"XML Parsing Error: no element found Location:... Line Number 1, Column 1:"
If I use remove for each module I have some success. As long as I leave at least 1 module. (Doesn't matter which one) When I remove the last module I get the same parsing error as the clear. Anyone have any idea why this error is happening? Is there any other way to eliminate web.config inheritance?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,最简单的解决方案是将您的应用程序设置为它自己的应用程序,因为正如您所指的,子文件夹包含一个应用程序。您仍然可以将用户链接回您的其他父应用程序。只需设置子文件夹即可将所有请求重定向到其他应用程序。对我来说,这听起来更像是一个架构问题,但我只是根据少量信息进行猜测。
另一个选项是,如果您的父应用程序引用 web.config 中的程序集,请将其排除在子应用程序中。
我的最后一个建议是,您可能只需要更好地拆分应用程序的源代码和引用并重新编译。
It sounds to me like the simplest solution is to set your application up as it's own application since the subfolder contains, as you refer to it, an application. You can still link users back to your other parent app. Just set the subfolder to do a redirect of all requests to the other application. It sounds more like an architectural issue to me but I am only guessing based on the small amount of information.
The other option is that if your parent app is referencing an assembly in web.config, exclude it in the child app.
My last suggestion would be that you may just need to split the source code and references of the apps up a little better and re-compile.