开发者

Programatically modifying system.web/webServices/protocols configuration section

I need to programatically add or modify the following section in an asp.net web.config file:

<configuration>
  <system.web&g开发者_运维百科t;
    <webServices>
        <protocols>
            <add name="HttpGet"/>
            <add name="HttpPost"/>
        </protocols>
    </webServices>
  </system.web>
</configuration>

I could manipulate the file at the XML level, but I prefer to use the configuration API whenever possible. I found ProtocolElement and ProtocolElementCollection classes, both in the System.Web.Services.Configuration namespace and in the System.Web.Services assembly, but after much googling I can't find any usage examples. I have the system.web.extensions/scripting/webServices sectionGroup defined in the configSections element - is that sufficient, or do I need to add a config section under that?

Any help manipulating this would be appreciated. We're currently using ASP.NET 2.0.


You should go with WebConfigurationManager and ConfigurationManager classes.

You can also take a look into this question: Changing values in Web.config with a Batch file or in .NET code

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜