首先添加引用: using System.Web.Configuration;
加密操作如下:
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();
}
}
解密操作如下:
伊图教程网[www.etoow.com]
http://www.etoow.com/html/2009-04/1240009596.html
private void UnProtectSection(string sectionName)
ASP.NET 2.0中配置文件的加密与解密
'http://www.etoow.com/html/2009-04/1240009596.html