加密web.config文件

时间:2016-08-23 20:39:45

标签: c# asp.net encryption asp.net-web-api connection-string

我正在尝试加密web.config文件的ConnectioString。我以管理员身份运行cmd并将以下commnad作为

C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -pef ProvantisDataConnection" "C:\inetpub\wwwroot\PSOC"

Encrypting configuration section...

The configuration section 'ProvantisDataConnection' was not found.

Failed!

我在web.config中的C:\inetpub\wwwroot\PSOC<connectionStrings>部分内有web.config文件,如下所示

<connectionStrings>
<add name="ProvantisDataConnection" connectionString="Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 10.00.00.0001)(PORT= 4321))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = ABC))));User Id=ABCD ;Password=ABCDD;pooling=true;min pool size=5;Max Pool Size=60" providerName="Oracle.DataAccess.Client" />
</connectionStrings>

但它仍然会失败。

1 个答案:

答案 0 :(得分:4)

运行aspnet_regiis时,需要指明要加密的节点的名称。您无法通过属性值选择要加密的内容。基本上,改变

aspnet_regiis -pef ProvantisDataConnection

aspnet_regiis -pef connectionStrings