我加密了web.config中的AppSettings部分,在本地测试通过,但上传到线上后出现错误:
我使用以下子程序进行加密:
配置错误描述:在处理所需的配置文件时发生错误。请查看以下特定错误详细信息,并相应地修改您的配置文件。
解析器错误消息:使用提供程序“DataProtectionConfigurationProvider”解密失败。提供程序返回的错误消息:密钥不适用于指定状态。(来自 HRESULT: 0x8009000B 的异常)
Line 24: <appSettings configProtectionProvider="DataProtectionConfigurationProvider">
Line 25: <EncryptedData>
我使用以下子程序进行加密:
Private Sub ProtectSection(ByVal sectionName As String, ByVal provider As String)
Dim config As Configuration = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)
Dim section As ConfigurationSection = config.GetSection(sectionName)
If section IsNot Nothing AndAlso Not section.SectionInformation.IsProtected Then
section.SectionInformation.ProtectSection(provider)
config.Save()
End If
End Sub