All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
Asp.net直接保存文件到客户端_[Asp.Net教程]
选择SQL,Server恢复模型确保正确备份_mssql学习_编程技术
通过PHP连接My,SQL的两种方法简介_php资料_编程技术
.Net,Framework3.0,实践纪实之布局_[Asp.Net教程]
跟我学SQL:(二),SELECT语句选项_mssql学习_编程技术
C#MD5算法_[Asp.Net教程]
AJAX入门之XMLHttpRequest慨述_[AJAX教程]
ASP.NET中的异常处理_[Asp.Net教程]
用ASP.NET2.0在数据库中存储二进制文件_[Asp.Net教程]
ASP.NET中动态生成Xml格式文档,并转换为HTML文件_[Asp.Net教程]
Reading number is top 10 pictures
影评-疯子,我爱你
职场回春术
A letter to parents choose world of warcraft seven big reason
girl of HuNan name is LiXiang(湖南辣姐李湘的写真)
The money of more than 100 countries and regions17
Sexy women in 2013--1
Exquisite decoration is not paying too much4
Look at the Spring Festival people crowded into the what kind
西游四格漫画(三)
天安门景物系列(一)
Download software ranking
Eclipse-CALMSANNY (second edition)
Professional killers2 data package
Sora aoi's film--cangkong_Blue.Sky
The cock of the Grosvenor LTD handsome
XML+Web+Service开发教程
Unix video tutorial10
Unix video tutorial1
Boxer's Top ten classic battle1
C#COM编程指南
金山office2007
归海一刀 published in(发表于) 2014/1/30 1:31:37 Edit(编辑)
加密和解密ASP.NET配置文件(Web.config)_[Asp.Net教程]

加密和解密ASP.NET配置文件(Web.config)_[Asp.Net教程]

加密和解密ASP.NET配置文件(Web.config)_[Asp.Net教程]
首先添加引用: 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();
}
}

解密操作如下:
private void UnProtectSection(string sectionName)
{
Configuration config =
WebConfigurationManager.
OpenWebConfiguration(Request.ApplicationPath);

ConfigurationSection section = config.GetSection(sectionName);

if (section != null && section.SectionInformation.IsProtected)
{
section.SectionInformation.UnprotectSection();
config.Save();
}
}
实践:
加密前的配置文件:











加密后的配置文件(Web.config):






AQAAANCMnd8BFdERjHoAwE/Cl+s
BAAAABi1ATlNkEUGEf0XyWGL2Xg
QAAAACAAAAAAADZgAAqAAAABAAA
ABIhxMWlazAntwIIpST1CDXAAAA
AASAAACgAAAAEAAAAPz/YKYx07c
b+h4fqdr4fkLgAAAAX1Ieyc+WSx
AfsDW1vn2C/fXsG2TAnYeUgaCov
8e3nGFTHHsH91gLiqKregFPYzGR
vW1xrez/3VwOmJI9eS7EFKrcXej
NnHL66kg2iNRk3ntLNZlZtTs3cZ
9w63u47VKAjs6miWsGBz2GntL/9
UGHLELigrJcr3YJ+lsjOscExQnv
HGvA48EfxpD+tEiFBtgXeHsFkQX
cqGySshx16vCt2GUNUC3ZmEAhBh
UsAFkPIYqelYHd4+m9a/xPe2tqw
GIbla1wbW2NDEfrzJPwnkfmpNqR
hXijKImipwXbDVYy6o0UAAAAs8D
suYNOhJ7qAjJa2c/4eUC7sks=










添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.