重慶分公司,新征程啟航
為企業提供網站建設、域名注冊、服務器等服務
為企業提供網站建設、域名注冊、服務器等服務
這篇文章主要介紹在web.config或者app.config中如何增加自定義配置節,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
10年的施秉網站建設經驗,針對設計、前端、開發、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。成都營銷網站建設的優勢是能夠根據用戶設備顯示端的尺寸不同,自動調整施秉建站的顯示方式,使網站能夠適用不同顯示終端,在瀏覽器中調整網站的寬度,無論在任何一種瀏覽器上瀏覽網站,都能展現優雅布局與設計,從而大程度地提升瀏覽體驗。創新互聯建站從事“施秉網站設計”,“施秉網站推廣”以來,每個客戶項目都認真落實執行。
簡單鍵值對
web.config
users.config
c#
NameValueCollection users = System.Configuration.ConfigurationManager.GetSection("users") as NameValueCollection; Response.Write(users.Keys[0]+""+users.Keys[1]);
復雜類型
web.config
roles.config
RolesCofig.cs
using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace EBuy.Chapter3.NTier.WebUI { public class RolesConfig : System.Configuration.IConfigurationSectionHandler { public object Create(object parent, object configContext, System.Xml.XmlNode section) { return section; } } }
c#
XmlNode roles= System.Configuration.ConfigurationManager.GetSection("roles") as XmlNode; Response.Write(roles.ChildNodes [0].Attributes["username"].InnerText);
還可以將配置節定義為一個實體
using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace EBuy.Chapter3.NTier.WebUI { public class RolesConfig : System.Configuration.IConfigurationSectionHandler { public object Create(object parent, object configContext, System.Xml.XmlNode section) { var list=new List(); for(int i=0;i var roles = System.Configuration.ConfigurationManager.GetSection("roles") as List; Response.Write(roles.First ().Username); 以上是“在web.config或者app.config中如何增加自定義配置節”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注創新互聯行業資訊頻道!
網站題目:在web.config或者app.config中如何增加自定義配置節
網站地址:http://www.xueling.net.cn/article/jehsss.html