我正在开发一个asp.net mvc web应用程序。我在我的web.config:-中定义了一个名为"customAppSettingsGroup"
的自定义分区组
<configuration>
<configSections>
<sectionGroup name="customAppSettingsGroup">
<section name="customAppSettings" type="System.Configuration.AppSettingsSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</sectionGroup>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<customAppSettingsGroup>
<customAppSettings>
<add key="KeyOne" value="*****"/>
</customAppSettings>
</customAppSettingsGroup>
......
......
</configuration>
现在我想加密该部分,主要是为了加密KeyOne值。所以我写了以下命令:-
C:WindowsMicrosoft.NETFramework64v4.0.30319>aspnet_regiis -pe "customAppSett
ingsGroup" -app "/Scanning" -prov "DataProtectionConfigurationProvider"
但我得到了以下错误:-
Microsoft (R) ASP.NET RegIIS version 4.0.30319.18408
Administration utility to install and uninstall ASP.NET on the local machine.
Copyright (C) Microsoft Corporation. All rights reserved.
Encrypting configuration section...
The configuration section 'customAppSettingsGroup' was not found.
Failed!
所以我不知道为什么commnad找不到相关的部分?
感谢
您的问题有两个方面。
-
无法加密分区组。您只能加密部分。因此,您的命令行需要从
customAppSettingsGroup
更改为customAppSettingsGroup/customAppSettings
。 -
regiis命令必须绑定到定义
customAppSettings
的DLL。有两种方法可以解决这个问题-要么在web.config的configSections
部分注释掉sectionGroup
块,要么将包含该定义的DLL复制到具有aspnet_regiis.exe的文件夹中。