【问题标题】:Encrypted & unencrypted connection strings in web.config?web.config中加密和未加密的连接字符串?
【发布时间】:2011-08-19 13:44:06
【问题描述】:

是否可以在同一个 web.config 中同时包含加密和未加密的连接字符串?

【问题讨论】:

    标签: asp.net .net-3.5 web-config


    【解决方案1】:

    我不相信您可以将单个连接字符串作为 ConnectionStrings 部分的一部分进行加密。这是因为 ConfigurationElement 对象(ConnectionStringSetting 派生自)有一个没有 Protect 方法的 ElementInformation 属性。 ConfigurationSection 具有 SectionInformation 属性,该属性确实具有 Protect 方法,ConnectionStringsSection 继承自 ConfigurationSection。

    因此,话虽如此,您可以加密 ConnectionStringsSection,但不能加密 ConnectionStringSetting。

    但是,一切都没有丢失。你确实有能力创建你的部分/元素来维护你的非加密(或加密,取决于你想走的路)连接字符串。您将无法使用 WebConfigurationManager 的 ConnectionStrings 属性访问它们。

    【讨论】:

      猜你喜欢
      • 2012-06-18
      • 2010-12-14
      • 1970-01-01
      • 2012-05-31
      • 1970-01-01
      • 1970-01-01
      • 2011-06-21
      • 1970-01-01
      • 2018-09-23
      相关资源
      最近更新 更多