2015-11-02 23 views
0

我正在研究一个asp.net mvc web应用程序。我已经定义了一个名为"customAppSettingsGroup"我的web.config中自定义栏目组: -aspnet_regiis无法找到自定义应用设置组

<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:\Windows\Microsoft.NET\Framework64\v4.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找不到相关的部分?

谢谢

回答

2

您的问题有两个方面。

  1. 您无法加密sectionGroups。您只能加密部分。所以你的命令行需要从customAppSettingsGroup更改为customAppSettingsGroup/customAppSettings

  2. 的regiis命令具有绑定到你的DLL的customAppSettings中定义有两种方法来解决这个问题 - 无论是在你的web.config的configSections部分注释掉sectionGroup块,或复制包含该DLL定义到具有aspnet_regiis.exe的文件夹中。