2015-11-02 24 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的文件夾中。