Web.Config继承问题 [英] Web.Config Inheritance Problem

查看:63
本文介绍了Web.Config继承问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想防止IIS 7应用程序中的父配置将以下部分下推到父应用程序下任何应用程序中的任何子web.configs.

I want to prevent the parent config in our IIS 7 app from pushing down the following section to any sub web.configs in any applications under the parent application.

    <configSections>
        <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
                <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                    <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
                    <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
                    <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
                    <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
                </sectionGroup>
            </sectionGroup>
        </sectionGroup>
    </configSections>

我需要删除该部分的原因是因为子应用程序不需要此甚至不使用它.因此,当父项将其传递给我并尝试运行该子应用程序时,在运行时会得到以下信息:

The reason I need to remove that section is because the sub application doesn't need this or even use it. So when the parent passes it down and I try to run that sub app, I get the following during runtime:

Unable to cast object of type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection' to type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection'

我无法阻止configSections向下应用到子应用程序web.configs.您不能在此特定部分周围用< location> 包裹它,而添加< clear/> 只会导致另一条错误消息,即:

I see no way to prevent the configSections from being applied downward to child application web.configs. You cannot wrap it with <location> around this particular section and adding a <clear/> only causes another error message which is:

The configuration section 'appSettings' cannot be read because it is missing a section declaration 

推荐答案

我相信您的运行时错误是由其他原因引起的,例如某种程序集冲突,或者仅仅是缺少的程序集.您发布的web.config片段几乎逐字存在于我继承的几个项目中,并且可以与子应用程序很好地配合使用.但是,它们引用的是旧版1.0.

I believe your runtime error is being caused by something else... like an assembly conflict of some kind, or just a missing assembly. The web.config snippet you posted exists almost verbatim in several projects of mine that I've inherited and works fine with sub apps. However they reference the old 1.0 versions.

错误消息甚至没有意义……无法将XYZ类型转换为XYZ类型."真的吗?你不能吗但是它们是同一类型!:|

The error message doesn't even make sense... "cannot cast type XYZ to type XYZ." Really? You can't? But they're the same type! :|

这篇关于Web.Config继承问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆