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

scalewingzip 2012-01-10 07:14:01
环境:
网站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" />

试了上面两个方法都不行
...全文
531 21 打赏 收藏 转发到动态 举报
写回复
用AI写文章
21 条回复
切换为时间正序
请发表友善的回复…
发表回复
romanyu 2014-06-27
  • 打赏
  • 举报
回复
方法:将主应用(网站A)下的version属性删除(verson=3.5.0.0,),将子应用(网站B)下的name="system.web.extensions"整节点删除,就可以运行了。
KeyrraTuff 2013-12-02
  • 打赏
  • 举报
回复
section allowDefinition = MachineToApplication 应该是你要的
Ahoo 2012-01-11
  • 打赏
  • 举报
回复
新建另一个网站。
scalewingzip 2012-01-11
  • 打赏
  • 举报
回复
大家帮帮忙!!!
scalewingzip 2012-01-11
  • 打赏
  • 举报
回复
刚刚试了 不行!@!
暗石绿 2012-01-11
  • 打赏
  • 举报
回复
都可以正确取到 EmailConfig 里的信息。
Core.EmailConfigHandler 是我定义的类。
暗石绿 2012-01-11
  • 打赏
  • 举报
回复
忘了说了,我是 win7 ,iis 7.5
暗石绿 2012-01-11
  • 打赏
  • 举报
回复
有点摸不着头脑。我作了一个测试:
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>
两个项目正确运行。
scalewingzip 2012-01-11
  • 打赏
  • 举报
回复
恩 是这行
暗石绿 2012-01-11
  • 打赏
  • 举报
回复
[Quote=引用楼主 scalewingzip 的回复:]
两个webconfig引用的 Extensions版本不一样 ,网站A可以运行,虚拟目录B就报错 “system.web.extensions”重复定义
怎么可以让B下的webconfig不继承A下的configSections
[/Quote]
出错行,是第几行?

<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
这一行吗?
net5354 2012-01-11
  • 打赏
  • 举报
回复
你要新建另外一程序池(用继承系统原程序池的方法才可以),虚拟目录就指定为新建的应用程序池
scalewingzip 2012-01-11
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 net5354 的回复:]

引用 4 楼 scalewingzip 的回复:
刚刚试了 不行!@!
你有什么版本的系统?
我在WIN2003测试过是可以的
[/Quote]

你的意思的 网站一个池,虚拟目录一个池吧 ,我试过了 失败!
系统也是2003
net5354 2012-01-11
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 scalewingzip 的回复:]
刚刚试了 不行!@!
[/Quote]你有什么版本的系统?
我在WIN2003测试过是可以的
scalewingzip 2012-01-11
  • 打赏
  • 举报
回复
哦 上面说错了
<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>


暗石绿 2012-01-11
  • 打赏
  • 举报
回复
那你把加了
<location path="." allowOverride="true" inheritInChildApplications="false">

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

这两行的B的Web.config内容贴出来看看。
scalewingzip 2012-01-11
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 xrascal 的回复:]

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

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

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

在B的web.config里配置的
暗石绿 2012-01-11
  • 打赏
  • 举报
回复
<location path="." allowOverride="true" inheritInChildApplications="false">

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

这两个方法,应该是可以的。
请问你是在A的web.config里,还是B的Web.config里进行配置的这两个标签?
scalewingzip 2012-01-11
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 tsgx_1989 的回复:]

新建另一个网站。
[/Quote]
没有别的办法啦?
net5354 2012-01-10
  • 打赏
  • 举报
回复
指定另外一个应用程序池就可以
scalewingzip 2012-01-10
  • 打赏
  • 举报
回复
????/
加载更多回复(1)

62,266

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧