从Web.Config中删除一个部分

时间:2009-10-14 19:03:19

标签: asp.net iis

我知道您可以使用<remove />删除密钥。我尝试使用它虽然我的web.config中的一节,我想你不能删除部分?如果我想删除整个组“webServices”??

,该怎么办?
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
    <remove section="jsonSerialization" />
    <remove section="profileService" />
    <remove section="authenticationService" />
    <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>

IIS正在通过以下错误消息对上述内容进行评估:

The requested page cannot be accessed because the related configuration data for the page is invalid.

它正在讨论上面的部分,从jsonSerialization和该组中的后续部分开始。

1 个答案:

答案 0 :(得分:2)

<section/>仅定义与该部分对应的类型。它不会添加部分本身。那么为什么要删除该部分?


BTW,<remove/>仅适用于某些集合。这些是

<add/>
<remove/>
<clear/>