有时候我们会在Web.Config配置文件自己定义一些节点来存放我们的信息,下面是一中读取的方法。
如“Web.Config”文件的“<configuration>”下又添加了一个节点,
<configSections>
<section name="bestitnet" type="BestItNet.Common.SectionHandler,bestitnet"/>
</configSections>
现在就是想获得“type”节点上的信息,方法如下:
using System.Xml; //引用命名空间
XmlDocument doc = new XmlDocument();
doc.Load(Request.PhysicalApplicationPath + "/web.config");
XmlNode node = doc.SelectSingleNode("configuration/configSections/section/@type");
Response.Write(node.Value);
浙公网安备 33010602011771号