我有一個自定義配置部分的Web應用程序。該部分包含我想要加密的信息(希望使用ASPNet_RegIIS而不是自己做)。使用ASPNet_Regiis加密自定義配置部分 - 你能做到嗎?
的Web.Config:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<configSections>
<section name="MyCustomSection"
type="MyNamespace.MyCustomSectionHandler, MyAssembly"/>
</configSections>
<configProtectedData>
<providers>
<clear />
<add name="DataProtectionConfigurationProvider"
type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL"
keyContainerName="MyKeyContainer"
useMachineContainer="true" />
</providers>
</configProtectedData>
<MyCustomSection>
<blah name="blah1">
<blahChild name="blah1Child1" />
</blah>
</MyCustomSection>
配置處理程序試圖加密前的偉大工程。當我嘗試將其與加密:
aspnet_regiis -pef "MyCustomSection" c:\inetpub\wwwroot\MyWebsite -prov DataProtectionConfigurationProvider
我得到一個錯誤:
Encrypting configuration section... An error occurred creating the configuration section handler for MyCustomSection: Could not load file or assembly 'MyAssembly' or one of its dependencies. The system cannot find the file specified. (c:\inetpub\wwwroot\MyWebsite\web.config line 5)
我已經試過有/無配置的提供者。有/無部分組。有/未事先啓動網站。我已經嘗試暫時將我的程序集放入GAC中進行註冊。我也試過我的log4net部分,只是爲了嘗試一些不屬於我的東西,沒有運氣。我以管理員身份運行命令提示符。有任何想法嗎?或者ASPNet_RegIIS只能用於自定義部分?
查看MSDN後最後一個鏡頭正在改變我的處理程序從ConfigurationSection繼承,而不是實現IConfigurationSectionHandler,因爲它在2.0技術上被棄用(希望它是關於aspnet_regiis版本)。那裏也沒有運氣。
任何想法讓我知道。謝謝!
我得到了同樣的問題。我不認爲有沒有辦法讓這個工作沒有將程序集放在gac中或在下面的答案中進行破解? – 2009-07-16 16:24:38
我厭倦了它的擺弄 - 所以我只是暫時把組裝放在gac中去了。 – 2009-07-16 21:23:02