(对Web.config文件加密)encrypting sensitive information stored in the web.config file
2007-04-22 13:46
453 查看
为了系统安全,需要对数据库的连接字符串进行加密:
1.引入Configuration名称空间 :
using System.Web.Configuration;
2.加密代码如下:
protected void EncryptConfig(bool bEncrypt)
...{
string path = "/SMTWeb";
Configuration config = WebConfigurationManager.OpenWebConfiguration(path);
ConfigurationSection appSettings = config.GetSection("connectionStrings");
if (bEncrypt)
...{
appSettings.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
}
else
...{
appSettings.SectionInformation.UnprotectSection();
}
config.Save();
}
1.引入Configuration名称空间 :
using System.Web.Configuration;
2.加密代码如下:
protected void EncryptConfig(bool bEncrypt)
...{
string path = "/SMTWeb";
Configuration config = WebConfigurationManager.OpenWebConfiguration(path);
ConfigurationSection appSettings = config.GetSection("connectionStrings");
if (bEncrypt)
...{
appSettings.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
}
else
...{
appSettings.SectionInformation.UnprotectSection();
}
config.Save();
}
相关文章推荐
- How to Modify the web.config file in SharePoint using SPWebConfigModification?
- SharePoint - Register an assembly as a safe control in the Web.config file
- .NET错误The 'targetFramework' attribute in the <compilation> element of the Web.config file is used only to target version 4.0 and later of the .NET Framework
- config the Cache in the file of Web.Config
- SharePoint - Register an assembly as a safe control in the Web.config file
- Register an assembly as a safe control in the Web.config file
- magento: Your web server is configured incorrectly. As a result, configuration files with sensitive information are accessible from the outside 解决方案
- The solution of html <input type = "file "> in webview not work
- Referenced file contains errors (http://www.springframework.org/schema/context). For more information, right click on the message in the Problems
- register controls in your web.config file
- The absolute uri: http://java.sun.com/jstl/core cannot be resolved in either web.xml or the jar file
- How to get the "connection string" from web.config file
- The web.config file for this project is missing the required DirectRequestModule.
- Weblogic发布小问题——The root element weblogic-web-app is missing in the descriptor file
- Use Microsofe log method and deploy the web.config file
- Unable to get the project file from the Web Server(in .NET 2005 IDE)
- The MagicAjax HttpModule is not included in web.config. Add [<httpModules><add name="MagicAjax" type="MagicAjax.MagicAja
- Create the web.config file programmatically
- [转]Publishing files stored in the file system through external list(使用bcs映射文件系统)
- Spring MVC looks for a file named [servlet-name]-servlet.xml in the WEB-INF