我看到其他几个人已经发布了这个问题,但是,我尝试过的解决方案都没有解决这个问题。我有一个运行 VS 2008 的 32 位 XP,我试图在我的 web.config 文件中加密我的连接字符串。
但是我得到了错误: 找不到配置部分“...”。失败了!
我给它的命令: C:\Program Files\Microsoft Visual Studio 9.0\VC>Aspnet_regiis.exe -pe "system.we b/AdventureWorksConnectionString2"-app "/Documents and Settings/Admin/My Docume nts/Visual Studio 2008/项目/AddFileToSQL2”
另外,-app 如何映射虚拟目录?换句话说,上面的路径是 c: 下面的目录。这是正确的使用路径吗? AddFileToSQL2 是我的项目的名称,尽管它是 AddFileToSQL 解决方案的一部分。
我有这个文件夹 web shared with all the permissions.
以及我的 web.config 文件的相关部分:
<add name="AdventureWorksConnectionString2" connectionString="Data Source=SIDEKICK;Initial Catalog=AdventureWorks;Persist Security Info=true; User ID=AdventureWorks;Password=sqlMagic"
providerName="System.Data.SqlClient" />
最佳答案
据我所知,使用 DPAPI 只能加密整个部分。因此,您不能只加密您的一个连接字符串,而是加密整个 connectionStrings 部分。其次,-app
指的是 IIS 服务器上应用程序的虚拟路径,它应该在其中找到给定的部分和配置文件。因此,如果您的网站看起来像这样:
root
/appFoo
并且您想加密/appFoo 中的连接字符串
aspnet_regiis -pe "connectionStrings"-app "/appFoo"
How To: Encrypt Configuration Sections in ASP.NET 2.0 Using DPAPI
关于c# - 如何保护 VS 中的连接字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2702325/