将网站放到托管的服务器上 如何保证数据库的安全啊
解决方案 »
- EXT 中Panel 控件里面显示HTML代码(相当于读取一段HTML文字)样式不显示
- AJAX 提示对象不支持此属性或方法
- 在ASP.NET中用百分比设置控件高度的问题
- 使用ASP.NET调用存储过程.出现错误,但不知道错在哪,请帮忙看看.谢谢
- 请教关于页面编码的疑问
- 为什么double型的3.15+3.15却等于6.299999999呢
- 关于如何实现用户登录即加分的问题
- 高分求CMS系统的开发资料,急,谢谢了:)
- 我们都是asp.net的自学者,录制了一些视频教程和大家分享!
- <asp:TemplateField HeaderText="变量"
- 自己的一个技术网站,邀编程人士交流!
- DropdownList 分页绑定页数控制
但是在Web.config中就能看到连接的地址和密码啊。
请高人提些意见吧,
保证数据库的安全
{
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.GetSectio n(sectionName);
if (section != null && section.SectionInformation.IsProtected)
{
section.SectionInformation.UnprotectSection();
config.Save();
} 你可以从一个ASP.NET页面中调用这个ProtectSection(sectionName,provider)方法,其相应的参数是一个节名(如connectionStrings)和一个提供程序(如DataProtectionConfigurationProvider),并且它打开Web.config文件,引用该节,调用SectionInformation对象的ProtectSection(provider)方法,最后保存配置变化。 另一方面,UnProtectSection(provider)方法实现解密一个特定的配置节。在此,仅需要传入要解密的节-我们不需要麻烦提供程序,因为该信息已经存储在伴随encrypted节的标记中(也即是,在上面的示例中的<connectionStrings>节,在被加密以后,它包含了提供程序:<connectionStringsconfigProtectionProvider="DataProtectionConfigurationProvider">)。 记住,一旦该数据被加密,当从一个ASP.NET页面读取它时(也即是,从一个SqlDataSource控件或以编程方式经由ConfigurationManager.ConnectionStrings[connStringName].ConnectionString读取该连接字符串信息),ASP.NET会自动地解密该连接字符串并且返回普通文本值。换句话说,在实现加密后,你一点不需要改变你的代码。相当酷,对不对?