【问题标题】:Get the decrypted content of the section in web.config without saving在不保存的情况下获取web.config中section的解密内容
【发布时间】:2013-11-12 05:58:48
【问题描述】:

如何在保存解密文件之前获取解密的 webconfig 部分的内容:confg.Save()

Dim confg As System.Configuration.Configuration = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)
Dim confgSect As ConfigurationSection = confg.GetSection("section")
If confgSect.SectionInformation.IsProtected Then
    confgSect.SectionInformation.UnprotectSection()
    confg.Save()
End If

【问题讨论】:

    标签: asp.net vb.net encryption configuration web-config


    【解决方案1】:
    Dim confg As System.Configuration.Configuration = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)
    Dim confgSect As ConfigurationSection = confg.GetSection("section")
    If confgSect.SectionInformation.IsProtected Then
        confgSect.SectionInformation.UnprotectSection()
        Dim xml As New System.Xml.XmlDocument
    
        Dim node As System.Xml.XmlNodeList
    
        Dim str As String
        Dim answer As String
    
        str = confgSect.SectionInformation.GetRawXml()
    
        xml.LoadXml("<ROOT>" + str + "</ROOT>")
        node = xml.GetElementsByTagName("TagnameHere")
        answer= node(0).Attributes(1).Value
    
    End If
    

    我在 webcobfig 中的部分包含多个标签,所以我使用 xml 来获取每个标签并将其值作为属性获取。

    【讨论】:

      猜你喜欢
      • 2014-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-12
      • 2023-03-18
      相关资源
      最近更新 更多