当前位置:编程学习 > C#/ASP.NET >>

虚拟目录下的webconfig不继承根目录的configSections

环境:
   网站A
   web.config

   <configSections>
      <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
</configSections>

   虚拟目录B

   web.config

   <configSections>
       <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
    </configSections>


两个webconfig引用的 Extensions版本不一样 ,网站A可以运行,虚拟目录B就报错 “system.web.extensions”重复定义
怎么可以让B下的webconfig不继承A下的configSections

<location path="." allowOverride="true" inheritInChildApplications="false">

<remove  name="system.web.extensions" />

试了上面两个方法都不行 --------------------编程问答-------------------- 怎么解决? --------------------编程问答-------------------- ????/ --------------------编程问答-------------------- 指定另外一个应用程序池就可以 --------------------编程问答-------------------- 刚刚试了 不行!@! --------------------编程问答-------------------- 大家帮帮忙!!! --------------------编程问答-------------------- 新建另一个网站。 --------------------编程问答--------------------
引用 6 楼 tsgx_1989 的回复:
新建另一个网站。

没有别的办法啦? --------------------编程问答-------------------- <location path="." allowOverride="true" inheritInChildApplications="false">

<remove name="system.web.extensions" />

这两个方法,应该是可以的。
请问你是在A的web.config里,还是B的Web.config里进行配置的这两个标签? --------------------编程问答--------------------
引用 8 楼 xrascal 的回复:
<location path="." allowOverride="true" inheritInChildApplications="false">

<remove name="system.web.extensions" />

这两个方法,应该是可以的。
请问你是在A的web.config里,还是B的Web.config里进行配置的这两个标签?


在B的web.config里配置的  --------------------编程问答-------------------- 那你把加了
<location path="." allowOverride="true" inheritInChildApplications="false">

<remove name="system.web.extensions" />

这两行的B的Web.config内容贴出来看看。 --------------------编程问答-------------------- 哦 上面说错了 
<location path="." allowOverride="true" inheritInChildApplications="false">
这个是加A下的web.config
不过这个没有包含<configSections>,因为包含了就报错,

所有只包含了除<configSections>的所有内容。

A中的Web.config 的相关内容如下



<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>
</sectiongroup>
  </configSections>

<location path="." allowOverride="true" inheritInChildApplications="false">
        ..
        ..
        ..
        ..
</location>





<remove name="system.web.extensions" />

是加到B里的


<configSections>
    <remove  name="system.web.extensions" />


    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">

      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
        <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>

        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
          <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
          <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
          <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
        </sectionGroup>

      </sectionGroup>

    </sectionGroup>

  </configSections>


--------------------编程问答--------------------
引用 4 楼 scalewingzip 的回复:
刚刚试了 不行!@!
你有什么版本的系统?
我在WIN2003测试过是可以的 --------------------编程问答--------------------
引用 12 楼 net5354 的回复:
引用 4 楼 scalewingzip 的回复:
刚刚试了 不行!@!
你有什么版本的系统?
我在WIN2003测试过是可以的


你的意思的 网站一个池,虚拟目录一个池吧 ,我试过了 失败!
系统也是2003  --------------------编程问答-------------------- 你要新建另外一程序池(用继承系统原程序池的方法才可以),虚拟目录就指定为新建的应用程序池 --------------------编程问答--------------------
引用楼主 scalewingzip 的回复:
两个webconfig引用的 Extensions版本不一样 ,网站A可以运行,虚拟目录B就报错 “system.web.extensions”重复定义
怎么可以让B下的webconfig不继承A下的configSections

出错行,是第几行?

 <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
 这一行吗? --------------------编程问答-------------------- 恩 是这行 --------------------编程问答-------------------- 有点摸不着头脑。我作了一个测试:
A项目为.net 3.5,B项目为 .net 2.0。
在A项目的web.config里加上:
<configSections>    
    <section name="EmailConfig" type="Core.EmailConfigHandler,Core"/>
</configSections>
<location path="." allowOverride="true" inheritInChildApplications="false">
    <system.web>
    ...
    ...
    </system.web>
</location>
在B项目的web.config里同样加上:
<configSections>    
    <section name="EmailConfig" type="Core.EmailConfigHandler,Core"/>
</configSections>
两个项目正确运行。 --------------------编程问答-------------------- 忘了说了,我是 win7 ,iis 7.5 --------------------编程问答-------------------- 都可以正确取到 EmailConfig 里的信息。
Core.EmailConfigHandler 是我定义的类。 --------------------编程问答-------------------- section allowDefinition = MachineToApplication

应该是你要的
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,