Asp.net 获取web.config中节的解密内容,而不保存

Asp.net 获取web.config中节的解密内容,而不保存,asp.net,vb.net,encryption,configuration,web-config,Asp.net,Vb.net,Encryption,Configuration,Web Config,在保存解密文件之前,如何获取解密webconfig节的内容:confg.Save() Dim confg As System.Configuration.Configuration=WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath) Dim confgSect As ConfigurationSection=confg.GETSECION(“section”) 如果confgSect.SectionInfor

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

Dim confg As System.Configuration.Configuration=WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)
Dim confgSect As ConfigurationSection=confg.GETSECION(“section”)
如果confgSect.SectionInformation.i受到保护,则
confgSect.SectionInformation.UnprotectSection()
Dim xml作为新System.xml.xml文档
Dim节点作为System.Xml.XmlNodeList
作为字符串的Dim str
模糊答案为字符串
str=confgSect.SectionInformation.GetRawXml()
LoadXml(“+str+”)
node=xml.GetElementsByTagName(“TagnameHere”)
答案=节点(0).属性(1).值
如果结束
webcobfig中的我的部分包含多个标记,因此我使用xml获取每个标记并将其值作为属性

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
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