Senator Guerra Souty original series calendar,replica hublot blue steel peach pointer collocation of rolex replica Rome digital scale, track type minute replica watches scale shows that the classical model is swiss replica watches incomparable, wearing elegant dress highlights.
mr-ponna.com

 

YOU ARE HERE: HOME Questions How to Encrypt Decrypt the web config file in NET



Encrypting/Decrypting web.config in .NET

View(s): 35057

How to Encrypt/Decrypt the web.config file in .NET?

Answer 1)


public static void mEncryptWebConfig(string appPath, string protectedSection, string dataProtectionProvider)
{
    System.Configuration.Configuration webConfig = WebConfigurationManager.OpenWebConfiguration(appPath);
    ConfigurationSection webConfigSection = webConfig.GetSection(protectedSection);

    if (!webConfigSection.SectionInformation.IsProtected)
    {
webConfigSection.SectionInformation.ProtectSection(dataProtectionProvider);  
        webConfig.Save();
    }
}

public static void mDecryptWebConfig(string appPath, string protectedSection)
{
    System.Configuration.Configuration webConfig = WebConfigurationManager.OpenWebConfiguration(appPath);
    ConfigurationSection webConfigSection = webConfig.GetSection(protectedSection);

    if (webConfigSection.SectionInformation.IsProtected)
    {
        webConfigSection.SectionInformation.UnprotectSection();
        webConfig.Save();
    }
}

  Asked in:  TCS (Tata Consultancy Services)   Expertise Level:  Experienced
  Last updated on Monday, 18 February 2013
4/5 stars (19 vote(s))

Register Login Ask Us Write to Us Help