开发者

How to encrypt Connectionstring written in web.config from codebehind?

I need to encrypt connectionstring and some appsettin开发者_运维百科gs keys value in web.config from code behind.

Please help.


Check these url - use aspnet_regiis.exe http://msdn.microsoft.com/en-us/library/zhhddkxy.aspx

http://msdn.microsoft.com/en-us/library/system.configuration.sectioninformation.protectsection.aspx


try this

private void ProtectSection(string sectionName,
                                   string provider)
    {
        Configuration config =
            WebConfigurationManager.
                OpenWebConfiguration(Request.ApplicationPath);

        ConfigurationSection section =
                     config.GetSection(sectionName);

        if (section != null &&
                  !section.SectionInformation.IsProtected)
        {
            section.SectionInformation.ProtectSection(provider);
            config.Save();
        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜