【问题标题】:How to encrypt Connectionstring written in web.config from codebehind?如何从后面的代码加密用 web.config 编写的连接字符串?
【发布时间】:2009-10-20 11:22:42
【问题描述】:

我需要从后面的代码中加密 web.config 中的连接字符串和一些 appsettings 键值。

请帮忙。

【问题讨论】:

    标签: c# .net asp.net web-config


    【解决方案1】:
    【解决方案2】:

    试试这个

    private void ProtectSection(string sectionName,
                                       string provider)
        {
            Configuration config =
                WebConfigurationManager.
                    OpenWebConfiguration(Request.ApplicationPath);
    
            ConfigurationSection section =
                         config.GetSection(sectionName);
    
            if (section != null &&
                      !section.SectionInformation.IsProtected)
            {
                section.SectionInformation.ProtectSection(provider);
                config.Save();
            }
        }
    

    【讨论】:

      猜你喜欢
      • 2012-05-31
      • 2012-06-18
      • 1970-01-01
      • 1970-01-01
      • 2011-08-19
      • 2010-12-14
      • 1970-01-01
      • 2011-10-02
      • 1970-01-01
      相关资源
      最近更新 更多