0

How can I get the content of the decrypted webconfig section before it saves the decrypted file: 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
4

1 回答 1

0
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 来获取每个标签并将其值作为属性获取。

于 2013-11-01T09:04:04.460 回答