使用Azure虚拟Web应用程序停止Web配置继承

问题描述:

我创建了一个Web应用程序项目并将其部署到Azure.

I have created a web application project and deployed it to Azure.

在此应用程序的web.config文件中,<system.web><compilation>元素中出现许多<assembly>元素.具体来说,这些程序集条目指向DevExpress程序集,但它们实际上可以是任何东西.

In the web.config file for this application, a number of <assembly> elements appear in the <system.web><compilation> element. Specifically, these assembly entries point to DevExpress assemblies but they could really be anything.

我还创建了一个Web API项目,该项目被部署为Web应用程序下的虚拟应用程序.看起来<assembly>条目是从Web应用程序的配置继承的. Web API项目不使用这些程序集,并引发异常,指出它们无法加载.

I have also created a Web API project that is deployed as a virtual application under the web application. It looks like the <assembly> entries are being inherited from the configuration of the web application. The Web API project does not use these assemblies and throws an exception stating that they cannot be loaded.

作为临时的解决方法,我已将程序集手动复制到Web API应用程序的bin文件夹中.但是,这不是永久解决方案.

As a temporary workaround, I have manually copied over the assemblies to the bin folder of the Web API application. However, this is not a permanent solution.

我尝试了清除 Web API配置中的程序集条目(使用<clear />元素).我还尝试了删除项(使用<remove>元素).这些都不起作用.

I have tried clearing the assembly entries in the Web API configuration (using the <clear /> element). I have also tried removing the entries (using the <remove> element). Neither of these worked.

阻止这种继承形式出现的最佳方法是什么?

What is the best way to stop this inheritance form occurring?

此官方

As mentioned in this official document about ASP.NET Configuration File Hierarchy and Inheritance:

ASP.NET应用程序的根目录> Web.config

特定ASP.NET应用程序的Web.config文件位于该应用程序的根目录中,并且包含适用于该Web应用程序的设置,并且向下遍历该目录中的所有子目录它的分支.

ASP.NET应用程序子目录> Web.config

应用程序子目录的Web.config文件包含适用于此子目录的设置,并向下继承其分支中的所有子目录.

The Web.config file for an application subdirectory contains settings that apply to this subdirectory and inherit downward through all of the subdirectories in its branch.

我认为您可以利用位置设置以实现您的目的.另外,还有一个有关设置和虚拟目录继承,您可以参考它.

I assumed that you could leverage Location Settings to achieve your purpose. Also, there is a blog about Settings and Virtual Directory Inheritance, you could refer to it.