您的位置:首页 > 编程语言 > ASP

ASP.NET 2.0 中一种新的方法实现对配置文件的加密

2007-05-20 17:37 1031 查看
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
string command = e.CommandName;
string path = e.CommandArgument.ToString();

if (path != "appSettings" && path != "connectionStrings")
path = "system.web/" + path;

Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
ConfigurationSection section = config.GetSection(path);

if (command == "Encrypt")
{
section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
config.Save();
}
else if (command == "Decrypt")
{
section.SectionInformation.UnprotectSection();
config.Save();
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: