IIS 中的嵌套 ASP.NET“应用程序"继承父配置值?

Nested ASP.NET #39;application#39; within IIS inheriting parent config values?(IIS 中的嵌套 ASP.NET“应用程序继承父配置值?)
本文介绍了IIS 中的嵌套 ASP.NET“应用程序"继承父配置值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在 IIS7 中有 2 个 ASP.NET 3.5 Web 应用程序(我们称它们为 WebParent 和 WebChild).

I currently have 2 x ASP.NET 3.5 web applications in IIS7 (lets call them WebParent and WebChild).

WebChild 嵌套在 IIS7 中的 WebParent 列表中,并设置为应用程序(而不仅仅是 WebParent 中的虚拟目录).目前两者都使用自己的(经典)应用程序池.

WebChild is nested within the WebParent listing in IIS7 and is set up as an application (rather than just a virtual directory within WebParent). Both currently use their own (Classic) application pool.

WebParent 和 WebChild 在各自的根目录中都有自己完全定义的 web.config 文件.

Both WebParent and WebChild have their own fully defined web.config files in their own root directories.

我曾假设 WebChild 被定义为 IIS 中的应用程序",它不会从 WebParent 配置文件继承任何内容.但是,尽管进行了这种配置,但我看到与 web.config 中的各种元素相关的错误已经被定义(这是正确的,两个配置文件中都有几个项目,但我认为它们应该完全独立于一个另一个)?

I had assumed that seeing as WebChild is defined as an 'Application' within IIS, that it would not inherit anything from the WebParent configuration file. However, despite this configuration, I am seeing errors related to various elements within the web.config already being defined (which is correct, there are a couple items that are in both config files, but I thought they should be treated completely independently from one another)?

谁能解释一下为什么会发生这种情况?

Can anyone please clarify why this might be occurring?

推荐答案

如果它们重复,你必须先<remove/>然后在子应用程序web.config中,然后添加回你想要的元素.这是假设您希望获得不同的值.如果你不这样做,那么只需省略该元素.连接字符串将是所有应用程序都可能通用的一个很好的例子 - 所以您只需在根目录中指定它.

If they are repeated, you'll have to <remove/> then in the child application web.config first, then add back the element you'd like it it's place. This is assuming that you'd like to have a different value. If you don't, then just omit the element. A connection string would be a good example of something that is likely common for all applications - so you only need to specify it in the root.

例子:

    <siteMap defaultProvider="AdminSiteMapProvider" enabled="true">
      <providers>
        <remove name="AdminSiteMapProvider"/>
        <add name="AdminSiteMapProvider" description="Admin SiteMap provider" type="System.Web.XmlSiteMapProvider" siteMapFile="~/App_Data/admin.sitemap" securityTrimmingEnabled="true" />
      </providers>
    </siteMap>

这篇关于IIS 中的嵌套 ASP.NET“应用程序"继承父配置值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
how do i pass parameters to aspnet reportviewer(如何将参数传递给aspnet report查看器)
Bind multiple parameters from route and body to a model in ASP.NET Core(在ASP.NET Core中将路由和主体中的多个参数绑定到一个模型)
Custom model binding in AspNet Core WebApi?(AspNet Core WebApi中的自定义模型绑定?)
How to minify in .net core mvc view?(如何在.Net核心MVC视图中缩小?)