'
'修改web.config文件appsettings配置节中的add里的属性
' '调用该函数后,会使整个web application重启,导致当前所有的会话丢失
' '<param name="key">要修改的键key</param>
' '<param name="str">修改后的</param>
Sub WriteConnStr() Sub WriteConnStr(ByVal key As String, ByVal str As String)
Dim xpath As String = "/configuration/appSettings/add[@key=""" + key + """]"
Dim WebConfig As New System.Xml.XmlDocument
WebConfig.Load(HttpContext.Current.Server.MapPath("web.config"))
Dim addkey As System.Xml.XmlNode = WebConfig.SelectSingleNode(xpath)
If addkey IsNot Nothing Then
addkey.Attributes("value").InnerText = str
WebConfig.Save(HttpContext.Current.Server.MapPath("web.config"))
End If
End Sub
' '调用该函数后,会使整个web application重启,导致当前所有的会话丢失
' '<param name="key">要修改的键key</param>
' '<param name="str">修改后的</param>
Sub WriteConnStr() Sub WriteConnStr(ByVal key As String, ByVal str As String)
Dim xpath As String = "/configuration/appSettings/add[@key=""" + key + """]"
Dim WebConfig As New System.Xml.XmlDocument
WebConfig.Load(HttpContext.Current.Server.MapPath("web.config"))
Dim addkey As System.Xml.XmlNode = WebConfig.SelectSingleNode(xpath)
If addkey IsNot Nothing Then
addkey.Attributes("value").InnerText = str
WebConfig.Save(HttpContext.Current.Server.MapPath("web.config"))
End If
End Sub