简体   繁体   English

ASP.NET Web.config <runtime>元素未继承到子应用程序

[英]ASP.NET Web.config <runtime> element not inherited into child application

I have an ASP.NET MVC5 application created as an IIS website with its own .NET 4.0 CLR app pool and physical path at: 我有一个ASP.NET MVC5应用程序作为IIS网站创建,具有自己的.NET 4.0 CLR应用程序池和物理路径:

C:\Websites\XXX\Web\en-HK

Under this site I have a child application "zh" in IIS (another MVC5 application), again with its own .NET 4.0 CLR app pool and physical path at: 在这个站点下,我在IIS(另一个MVC5应用程序)中有一个子应用程序“zh”,同样具有自己的.NET 4.0 CLR应用程序池和物理路径:

C:\Websites\XXX\Web\zh-Hans-HK

Both sites have their own web.configs, with the child one only overriding a single <appSetting> which is working. 两个站点都有自己的web.configs,其中一个站点只覆盖一个正在运行的<appSetting> What is not working however is that the element in the parent does no appear to be inherited down. 然而,不起作用的是,父元素中的元素似乎没有被继承下来。 The element looks like: 该元素看起来像:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.0.0" newVersion="5.2.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

When I first run the child application in a browser I see a YSOD complaining about that MVC 3.0 can't be found - this is because a 3rd party DLL is looking for MVC 3 but the binding that should redirect to 5.2 isn't there. 当我第一次在浏览器中运行子应用程序时,我看到一个YSOD抱怨无法找到MVC 3.0 - 这是因为第三方DLL正在寻找MVC 3但是应该重定向到5.2的绑定不存在。

If I paste the <runtime> element into the child web.config - the error goes away. 如果我将<runtime>元素粘贴到子web.config中 - 错误就会消失。

Is the <runtime> element prevented from being inherited in child application by design or is my set-up off? <runtime>元素是否被设计阻止在子应用程序中继承,或者我的设置是否已关闭? It doesn't appear to be protected in machine.config. 它似乎没有在machine.config中受到保护。

UPDATE UPDATE

I think the issue is to do with assembly probing. 我认为这个问题与装配探测有关。

When I've enabled the assembly load trace I can see that the YSOD in the child app is caused by ELMAH's dependency on MVC3, when .NET probes the application config (my child apps web.config) it cant find any <assemblyBinding> info so moves on to check the aspnet.config , not my parent sites web.config which does have the <assemblyBinding> info. 当我启用程序集加载跟踪时,我可以看到子应用程序中的YSOD是由ELMAH对MVC3的依赖引起的,当.NET探测应用程序配置(我的子应用程序web.config)时,它无法找到任何<assemblyBinding> info所以继续检查aspnet.config而不是我的父网站web.config确实有<assemblyBinding>信息。

在此输入图像描述

I guess this behaviour is by design? 我猜这种行为是设计的?

The Asp.Net engine composes your Web.config files following IIS hierarchy into a final configuration source that the .Net runtime uses for requests within specific web locations Asp.Net引擎将IIS层次结构后的Web.config文件组合成.Net运行时用于特定Web位置内的请求的最终配置源

However, the <runtime> section is a bit special because it is so low level. 但是, <runtime>部分有点特殊,因为它的级别很低。 It is not used by managed code but by the unmanaged .Net runtime host to define its overall behavior (assembly binding is the most common but GC related stuff and others) 它不是由托管代码使用,而是由非托管的.Net运行时宿主用于定义其整体行为(程序集绑定是最常见但与GC相关的内容和其他内容)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM