首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Encryption ConnectionStrings App.config

Encryption ConnectionStrings App.config
EN

Stack Overflow用户
提问于 2015-11-10 13:24:33
回答 1查看 288关注 0票数 0

我已经尝试用下面的代码加密,但它只能在我的PC上使用,其他PC无法连接到我PC中的SQL server。有没有人帮我?非常感谢!(我也尝试过aspnet_regiis.exe,但也遇到了同样的问题)

代码语言:javascript
复制
        public static void ProtectSection(String sSectionName)
    {
        Configuration config = ConfigurationManager.OpenExeConfiguration("TFLManager.exe");

        // Get the section in the file.
        ConnectionStringsSection section = config.GetSection(sSectionName) as ConnectionStringsSection;
        // If the section exists and the section is not readonly, then protect the section.
        if (section != null)
        {
            if (!section.IsReadOnly())
            {
                // Protect the section.
                section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
                section.SectionInformation.ForceSave = true;
                // Save the change.
                config.Save(ConfigurationSaveMode.Modified);
            }
        }
    }
EN

回答 1

Stack Overflow用户

发布于 2018-05-13 14:21:40

在所需的计算机上以管理员身份启动命令提示符。在命令提示下,输入:

代码语言:javascript
复制
 cd C:\Windows\Microsoft.NET\Framework\v4.0.30319

如果您的web配置位于"D:\Code\EncryptWebConfig“目录路径中,请输入以下内容以加密ConnectionString:

代码语言:javascript
复制
ASPNET_REGIIS -pef "connectionStrings" "D:\Code\EncryptWebConfig"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33623442

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档