El TecnoBaúl de Kiquenet

Kiquenet boring stories

Posts Tagged ‘encriptar secciones configuration web.config’

Encriptar Secciones de Config

Posted by kiquenet en 5 mayo 2010

Una forma de hacerlo:

protected void EncryptConfig(bool bEncrypt) 
{

object path = "/EXAMPLE"; 
Configuration config1 = 
WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);

ConfigurationSection section1 = config1.GetSection("connectionStrings"); 
ConfigurationSection section2 = config1.GetSection("system.net/mailSettings/smtp"); 
 

if (bEncrypt) 
{

section1.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
section2.SectionInformation.ProtectSection("DataProtectionConfigurationProvider"); 
}

else

{

section1.SectionInformation.UnprotectSection();

section2.SectionInformation.UnprotectSection();

}

config1.Save();

}

Posted in .NET | Etiquetado: | Leave a Comment »