Monday, 12 August 2013

Encript Web.config file using asp.net c#

Step-1 -Run VS as administrator
   
protected void btn_encriptConfig_Click(object sender, EventArgs e)
    {      
        Encryption(true);
    }

    protected void Encryption(bool EncryptoValue)
    {

        Configuration config =WebConfigurationManager.OpenWebConfiguration("~");
        ConfigurationSection sec = config.GetSection("connectionStrings");
        if (EncryptoValue == true)
        {
            sec.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
        }
        else
        {
            sec.SectionInformation.UnprotectSection();
        }
        config.Save();
    }

No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...