Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can do it using its "loosely" typed model, basically for reading it for Default Web Site would look like:</p> <pre><code>using (ServerManager serverManager = new ServerManager()) { Configuration webConfig = serverManager.GetWebConfiguration("Default Web Site"); ConfigurationSection section = webConfig.GetSection("system.webServer/defaultDocument"); foreach (ConfigurationElement item in section.GetCollection("files")) { Console.WriteLine(item["value"]); } } </code></pre> <p>You can also generate strongly-typed wrappers for collections and entries you want to use frequently which makes it a lot cleaner and prevents mistakes, that would make it look like:</p> <pre><code>using (ServerManager serverManager = new ServerManager()) { Configuration webConfig = serverManager.GetWebConfiguration("Default Web Site"); DefaultDocumentSection section = (DefaultDocumentSection)webConfig.GetSection("system.webServer/defaultDocument", typeof(DefaultDocumentSection)); foreach (FileElement item in section.Files) { Console.WriteLine(item.Value); } } </code></pre> <p>And for that to work you need the following "strongly-typed-wrappers":</p> <pre><code>public class DefaultDocumentSection : ConfigurationSection { private FilesCollection _files; public FilesCollection Files { get { if (_files == null) { _files = (FilesCollection)base.GetCollection("files", typeof(FilesCollection)); } return _files; } } } public class FilesCollection : ConfigurationElementCollectionBase&lt;FileElement&gt; { protected override FileElement CreateNewElement(string elementTagName) { return new FileElement(); } } public class FileElement : ConfigurationElement { public string Value { get { return (string)base["value"]; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload