[英]Encrypt Web.Config (Web.Release.config) Transform files using aspnet_regiis
[英]Encrypt App or Web.config using aspnet_regiis - Section 'xyz' not found
我的app.web.config具有自定义配置部分NameValueSectionHandler
,但是aspnet_regiis找不到它。
我需要将我的WPF应用程序部署到加密了app.config的多台计算机上。 我已经尝试过使用aspnet_regiis进行许多演练,但是没有任何效果。 我试过了:
aspnet_regiis -pc LiteContainer -exp
aspnet_regiis -pef connectionSettings D:\\Tes -prov LiteProvider
错误是
“找不到配置节'connectionSettings'”。
失败!
但是我可以通过代码成功地将数据读/写到此部分。
应用/ Web.config中
<configuration>
<configSections>
<section name="connectionSettings" type="System.Configuration.NameValueSectionHandler"/>
<sectionGroup name="userSettings" .... </sectionGroup>
</configSections>
<connectionSettings>
<server>192.168.1.xxx</server>
<database>myDb</database>
<uid>root</uid>
<pwd>123</pwd>
</connectionSettings>
<configProtectedData>
<providers>
<add name="LiteProvider"
keyContainerName="LiteContainer"
useMachineContainer="true"
description="Uses RsaCryptoServiceProvider to encrypt and decrypt"
type="System.Configuration.RsaProtectedConfigurationProvider/>
</providers>
</configProtectedData>
</configuration>
我之前没有见过任何演练对NameValueSectionHandler
进行加密,许多使用过的applicationSettings
或connectionStrings
。 我在这里想念什么?
我认为您的命令是错误的,即使文件夹D:\\ Tes包含您的web.config:
aspnet_regiis -pef connectionSettings D:\\Tes -prov LiteProvider
您输入的是connectionSettings而不是connectionStrings :
%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -pef "connectionStrings" <full path to directory containing web.config file>
语法不是aspnet_regiis -pef [节名] [web.config路径]吗? 该部分的名称是connectionSettings而不是connectionStrings
这是在PC上尝试时的结果。
将具有AppSettings( 或ConnectionStrings )部分的App.Config复制到C:\\ Temp,并将其重命名为Web.config。
运行此命令:%windir%\\ Microsoft.NET \\ Framework \\ v2.0.50727 \\ aspnet_regiis -pef“ appSettings” c:\\ Temp
运行aspnet_regiis命令后,将对appSettings进行加密:
您的XML格式不符合预期,例如:
<server>192.168.1.xxx</server>
<database>myDb</database>
<uid>root</uid>
使用标准的appSettings或connectionStrings格式:
<appSettings>
<add key="server" value="192.168.1.xxx"/>
<add key="database" value="myDb"/>
<add key="uid" value="root"/>
<add key="pwd" value="123"/>
</appSettings>
参考: https : //social.msdn.microsoft.com/Forums/windows/zh-CN/3b5a1d1f-aa57-40d8-8607-fee0b2a8a6db/protect-appconfig-file-or-encrypt? forum =winforms
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.