【问题标题】:Programatically modifying system.web/webServices/protocols configuration section以编程方式修改 system.web/webServices/protocols 配置部分
【发布时间】:2010-01-05 20:38:01
【问题描述】:

我需要以编程方式在 asp.net web.config 文件中添加或修改以下部分:

<configuration>
  <system.web>
    <webServices>
        <protocols>
            <add name="HttpGet"/>
            <add name="HttpPost"/>
        </protocols>
    </webServices>
  </system.web>
</configuration>

我可以在 XML 级别操作文件,但我更喜欢尽可能使用配置 API。我在 System.Web.Services.Configuration 命名空间和 System.Web.Services 程序集中都找到了 ProtocolElement 和 ProtocolElementCollection 类,但经过大量谷歌搜索后,我找不到任何使用示例。我在 configSections 元素中定义了 system.web.extensions/scripting/webServices sectionGroup - 这足够了吗,还是我需要在其下添加一个配置部分?

如有任何帮助,我们将不胜感激。我们目前使用的是 ASP.NET 2.0。

【问题讨论】:

    标签: asp.net asp.net-2.0


    【解决方案1】:

    【讨论】:

    • 感谢您的建议;但是,我已经在使用 ConfigurationManager 和 WebConfigurationManager。更新“基础”(即应用程序设置、连接字符串等)很容易;挑战在于 web.config 文件(system.web 等)中更深奥的部分。我可能会继续通过 XML 来完成这项工作。
    猜你喜欢
    • 2012-10-09
    • 1970-01-01
    • 2011-06-18
    • 2011-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-02
    相关资源
    最近更新 更多