gpt4 book ai didi

asp.net - 加密web.config后出错

转载 作者:行者123 更新时间:2023-12-01 01:37:39 24 4
gpt4 key购买 nike

我加密了我的 web.config 的 AppSettings 部分,在我的机器上测试它并且它工作,但是当我上传到在线使用它时它给了我一个错误:

Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Failed to decrypt using provider 'DataProtectionConfigurationProvider'. Error message from the provider: Key not valid for use in specified state. (Exception from 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

最佳答案

您需要在解密的部分发布。用于加密/解密的 key 是特定于机器的。

要在线加密配置部分,请调用 global.asax 的 Application_Start() 中的 ProtectSection() 方法。

关于asp.net - 加密web.config后出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/788459/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com