0

I have try to encrypt with code below, but it can use only on my PC, other PC can't connect to SQL server in my PC. anyone help me? thanks so much!!! (I also try with aspnet_regiis.exe but have same problem)

        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);
            }
        }
    }
Ricky
  • 1

1 Answers1

0

launch your Command prompt as an Administrator on the computer you want. At the Command Prompt, enter:

 cd C:\Windows\Microsoft.NET\Framework\v4.0.30319

In case your web Config is located in "D:\Code\EncryptWebConfig" directory path, then enter the following to encrypt the ConnectionString:

ASPNET_REGIIS -pef "connectionStrings" "D:\Code\EncryptWebConfig"
Maryam Ghafarinia
  • 417
  • 1
  • 5
  • 21