在Visual Studio 2012中,我正在研究ASP.NET MVC应用程序,该应用程序需要在名为“Shared”的主应用程序目录下有一个虚拟目录。 这恰好指向一个UNCpath,所以我还需要指定用户名和密码来访问path。
我正在使用以下命令:
C:\Program Files\IIS Express> AppCmd.exe SET VDir /username:"DOMAIN\user" /password:"Password"
但是,当我运行该应用程序时,尝试访问共享虚拟目录时出现以下configuration错误:
Failed to decrypt attribute 'password' because the keyset does not exist
错误屏幕然后突出显示我的applicationHost.config文件中相应的<virtualDirectory>元素:
<virtualDirectory path="/Shared" physicalPath="\\MyNAS\MyUNCPath\Shared" userName="DOMAIN\user" password="[enc:RsaProtectedConfigurationProvider:ALONGENCRYPTIONSTRINGISHERE==:enc]" />
现在,我疯狂search了几个小时,并且看到了一些注释,指出在这种情况下,我的密码的默认(正确?)encryptiontypes应该是“AesProvider”而不是“RsaProtectedConfigurationProvider”。 但是在设置密码的时候,似乎没有任何明确声明encryption提供者使用的方法。
如果有帮助,我applicationHost.config的提供者列表如下所示:
<configProtectedData> <providers> <add name="IISWASOnlyRsaProvider" type="" description="Uses RsaCryptoServiceProvider to encrypt and decrypt" keyContainerName="iisWasKey" cspProviderName="" useMachineContainer="true" useOAEP="false" /> <add name="AesProvider" type="Microsoft.ApplicationHost.AesProtectedConfigurationProvider" description="Uses an AES session key to encrypt and decrypt" keyContainerName="iisConfigurationKey" cspProviderName="" useOAEP="false" useMachineContainer="true" sessionKey="ALONGENCRYPTIONKEYSTRINGISHERE" /> <add name="IISWASOnlyAesProvider" type="Microsoft.ApplicationHost.AesProtectedConfigurationProvider" description="Uses an AES session key to encrypt and decrypt" keyContainerName="iisWasKey" cspProviderName="" useOAEP="false" useMachineContainer="true" sessionKey="ANOTHERENCRYPTIONKEYSTRINGISHERE" /> </providers> </configProtectedData>
我的直觉说这里有一些错误configuration,但我不知道如何识别和解决问题。 有任何想法吗?