加密.net Core 2中的connectionStrings部分

时间:2017-09-28 11:10:48

标签: .net core

传统上我会使用类似下面的内容

            // Open the configuration file and retrieve 
            // the connectionStrings section.
            Configuration config = ConfigurationManager.OpenExeConfiguration(exeConfigName);

            ConnectionStringsSection section = config.GetSection("connectionStrings") as ConnectionStringsSection;

            if (section.SectionInformation.IsProtected)
            {
                // Remove encryption.
                section.SectionInformation.UnprotectSection();
            }
            else
            {
                // Encrypt the section.
                section.SectionInformation.ProtectSection(
                    "DataProtectionConfigurationProvider");
            }
            // Save the current configuration.
            config.Save();

是否有可以在.net Core 2中使用的方法,其中connectionString存储在appSettings.json中?

0 个答案:

没有答案