天天看点

加密配置节

 protected void button1_click(object sender, eventargs e)

{

configuration config = webconfigurationmanager.openwebconfiguration(request.applicationpath);

configurationsection appsettings = config.getsection("connectionstrings");

if (appsettings.sectioninformation.isprotected)

appsettings.sectioninformation.unprotectsection();

lblinfo.text = "配置节已解密!";

}

else

appsettings.sectioninformation.protectsection( "dataprotectionconfigurationprovider");

button1.text = "解密";

lblinfo.text = "已加密配置节!";

config.save();

继续阅读