Encryptingweb.config后出错 [英] Error After Encryptingweb.config

查看:140
本文介绍了Encryptingweb.config后出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



< blockquote>

配置错误说明:在处理

之前发生

服务此请求的配置文件。请查看
下面的具体错误详细信息,
正确修改配置文件



解析器错误消息:$ b $失败b使用提供者
'DataProtectionConfigurationProvider'进行解密。
来自提供者的错误消息:Key
在指定状态下无效。
(HRESULT的异常:0x8009000B)




 第24行:< appSettings configProtectionProvider = DataProtectionConfigurationProvider > 
第25行:<加密数据>

我使用以下子加密:

  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)

如果section IsNot Nothing AndAlso不是section.SectionInformation.IsProtected然后
section.SectionInformation.ProtectSection(provider)
config.Save ()
End If
End Sub


解决方案

您需要使用解密部分进行发布。用于加密/解密的密钥是特定于机器的。



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


I encrypted the AppSettings part of my web.config, tested it on my machine and it worked, but when I uploaded to use it online it gave me an error:

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>

I used the following sub to encrypt:

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

解决方案

You need to publish with the section decrypted. The key that is used to encrypt/decrypt is machine specific.

To encrypt the config sections online call the ProtectSection() method in Application_Start() of global.asax.

这篇关于Encryptingweb.config后出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆