<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.iis.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:cs="http://blogs.iis.net/"><channel><title>Dave&amp;#39;s Blog : IIS7</title><link>http://blogs.iis.net/davcox/archive/tags/IIS7/default.aspx</link><description>Tags: IIS7</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Where is Execute Permission in the UI?</title><link>http://blogs.iis.net/davcox/archive/2008/09/05/where-is-execute-permission-in-the-ui.aspx</link><pubDate>Fri, 05 Sep 2008 17:26:00 GMT</pubDate><guid isPermaLink="false">50bcf3b4-f6fe-4638-adff-0c150e922e99:2603468</guid><dc:creator>davcox</dc:creator><slash:comments>9</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.iis.net/davcox/rsscomments.aspx?PostID=2603468</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.iis.net/davcox/commentapi.aspx?PostID=2603468</wfw:comment><comments>http://blogs.iis.net/davcox/archive/2008/09/05/where-is-execute-permission-in-the-ui.aspx#comments</comments><description>A lot has changed in the IIS7 UI from IIS6, sometimes it can be hard to find out where to set certain things such as the execute permission for CGI's and ISAPI's. Yesterday, I was trying to get a CGI to execute, but couldn't find where to set it. In IIS7...(&lt;a href="http://blogs.iis.net/davcox/archive/2008/09/05/where-is-execute-permission-in-the-ui.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.iis.net/aggbug.aspx?PostID=2603468" width="1" height="1"&gt;</description><category domain="http://blogs.iis.net/davcox/archive/tags/UI/default.aspx">UI</category><category domain="http://blogs.iis.net/davcox/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.iis.net/davcox/archive/tags/IIS7/default.aspx">IIS7</category></item><item><title>Accessing custom properties at runtime through managed modules (part 2)</title><link>http://blogs.iis.net/davcox/archive/2007/11/21/accessing-custom-properties-at-runtime-through-managed-modules-part-2.aspx</link><pubDate>Wed, 21 Nov 2007 19:53:00 GMT</pubDate><guid isPermaLink="false">50bcf3b4-f6fe-4638-adff-0c150e922e99:2019494</guid><dc:creator>davcox</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.iis.net/davcox/rsscomments.aspx?PostID=2019494</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.iis.net/davcox/commentapi.aspx?PostID=2019494</wfw:comment><comments>http://blogs.iis.net/davcox/archive/2007/11/21/accessing-custom-properties-at-runtime-through-managed-modules-part-2.aspx#comments</comments><description>&lt;P mce_keep="true"&gt;Ok, now I want to do something in my managed module during runtime that will only read from my custom configuration properties.&lt;/P&gt;
&lt;P mce_keep="true"&gt;I need someplace to start ... like a starter kit!&amp;nbsp; :)&amp;nbsp; &lt;BR&gt;&lt;A href="http://www.iis.net/downloads/default.aspx?tabid=34&amp;amp;i=1302&amp;amp;g=6" mce_href="http://www.iis.net/downloads/default.aspx?tabid=34&amp;amp;i=1302&amp;amp;g=6"&gt;http://www.iis.net/downloads/default.aspx?tabid=34&amp;amp;i=1302&amp;amp;g=6&lt;/A&gt;&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;This helps me get started, but it doesn’t tell me about the other events to get callbacks on as my module runs ... I realized finally that an IIS managed module is really an ASP.net module as far as it's ability to interface with&amp;nbsp;the IIS pipeline.&amp;nbsp; So I took a look at the ASP.net integration articles.&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;Finally, I found this article:&lt;BR&gt;&lt;A href="http://www.iis.net/articles/view.aspx/IIS7/Hosting-Web-Applications/ASP-NET/ASP-NET-Integration-with-IIS7?Page=3" mce_href="http://www.iis.net/articles/view.aspx/IIS7/Hosting-Web-Applications/ASP-NET/ASP-NET-Integration-with-IIS7?Page=3"&gt;http://www.iis.net/articles/view.aspx/IIS7/Hosting-Web-Applications/ASP-NET/ASP-NET-Integration-with-IIS7?Page=3&lt;/A&gt;&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;I have my modules working, the starter kit was very helpful to get my Visual studio project&amp;nbsp;setup properly.&amp;nbsp;&amp;nbsp;Athough it didn’t have a reference to&amp;nbsp;Microsoft.Web.Administration which may be a common issue; something to add for future starter kits.&amp;nbsp; This is an important issue that I realized later.&amp;nbsp; Most asp.net modules will be using System.Configuration which does not support the&amp;nbsp;custom properties you add through IIS and the custom schema we've described.&amp;nbsp; Instead, you must use Microsoft.Web.Administration to access this kind of configuration.&amp;nbsp; These two API's unfortunately don't always play well together, so you need to know when you're using which one and why.&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;Ok, now to deploy my module … seems hard to find a good example of doing this … probably some arcane appcmd command that would do it. I’ll copy and paste config for now … oops, the web.config default in the starter kit didn’t have preCondition="managedHandler" in there … &lt;/P&gt;
&lt;P mce_keep="true"&gt;Ok, I copied my module to the test machine and am trying to make requests ... but it gives me an error saying that it cannot read configuration!&amp;nbsp; Hmm, why is this?&amp;nbsp; What would be different about using the same configuration code in a console (running as the Administrator) and in the IIS pipeline (running as Network Service).&amp;nbsp; Well, the permission's were set properly, both of them can read configuration.&amp;nbsp; But I didn't realize that ServerManager object (in Microsoft.Web.Administration) opens up config for write access, which is not allowed!&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;I have to use WebConfigurationManager instead of ServerManager …and luckily MSDN helps me: &lt;A href="http://msdn2.microsoft.com/en-us/library/system.web.configuration.webconfigurationmanager.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.web.configuration.webconfigurationmanager.aspx"&gt;http://msdn2.microsoft.com/en-us/library/system.web.configuration.webconfigurationmanager.aspx&lt;/A&gt;&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;And&amp;nbsp;I found out later that Carlos had just blogged about this!&amp;nbsp; but the search engines had not yet found this great blog post:&lt;BR&gt;&lt;A href="http://blogs.msdn.com/carlosag/archive/2007/09/28/IIS7ManagedConfigurationAPI.aspx" mce_href="http://blogs.msdn.com/carlosag/archive/2007/09/28/IIS7ManagedConfigurationAPI.aspx"&gt;http://blogs.msdn.com/carlosag/archive/2007/09/28/IIS7ManagedConfigurationAPI.aspx&lt;/A&gt;&amp;nbsp; This is where Carlos goes into some detail about the difference between using design-time and run-time API's (which he implemented).&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;Great!!&amp;nbsp; Now my module is working ... here is a code snippet:&lt;/P&gt;
&lt;P mce_keep="true"&gt;using System;&lt;BR&gt;using System.Collections.Generic;&lt;BR&gt;using System.IO;&lt;BR&gt;using System.Web;&lt;BR&gt;using System.Diagnostics;&lt;BR&gt;using Microsoft.Web.Administration;&lt;/P&gt;
&lt;P mce_keep="true"&gt;namespace MyIIS7Modules&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public class PonyModule : IHttpModule&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void Init(HttpApplication application)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Subscribe to the BeginRequest event &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; application.BeginRequest += new EventHandler(this.CheckForPony);&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void Dispose()&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void CheckForPony(Object source, EventArgs e)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HttpApplication application = (HttpApplication)source;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HttpContext context = application.Context;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string HttpUrl = application.Request.Url.ToString().ToLower();&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// if this is a PONY request, then let's handle it, otherwise just continue&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (HttpUrl.Contains("pony"))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Get the custom configuration section from that file&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ConfigurationSection section = WebConfigurationManager.GetSection("ENC-Pony");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool PonyAnswer = (bool)section.GetAttributeValue("CanIHaveAPonyPlease");&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; application.Response.StatusCode = 200;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (PonyAnswer)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ResponseEntity += ("&amp;lt;H1&amp;gt;" + section.GetAttributeValue("YesResponse") + "&amp;lt;/H1&amp;gt;&amp;lt;BR&amp;gt;");&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;At a later date, I'll post my entire module with a brief overview of it's capabilities and how to use it.&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;Dave &lt;/P&gt;&lt;img src="http://blogs.iis.net/aggbug.aspx?PostID=2019494" width="1" height="1"&gt;</description><category domain="http://blogs.iis.net/davcox/archive/tags/IIS7/default.aspx">IIS7</category><category domain="http://blogs.iis.net/davcox/archive/tags/Config/default.aspx">Config</category><category domain="http://blogs.iis.net/davcox/archive/tags/Managed+Code/default.aspx">Managed Code</category></item><item><title>Accessing custom properties at runtime through managed modules (part 1)</title><link>http://blogs.iis.net/davcox/archive/2007/11/21/accessing-custom-properties-at-runtime-through-managed-modules-part-1.aspx</link><pubDate>Wed, 21 Nov 2007 19:25:00 GMT</pubDate><guid isPermaLink="false">50bcf3b4-f6fe-4638-adff-0c150e922e99:2019436</guid><dc:creator>davcox</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.iis.net/davcox/rsscomments.aspx?PostID=2019436</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.iis.net/davcox/commentapi.aspx?PostID=2019436</wfw:comment><comments>http://blogs.iis.net/davcox/archive/2007/11/21/accessing-custom-properties-at-runtime-through-managed-modules-part-1.aspx#comments</comments><description>&lt;P mce_keep="true"&gt;Following on my last post in developing my module for app-building week, I want to talk about how I wrote the code for my managed module (C# code).&amp;nbsp; So far, I have custom configuration schema that could be accessed through various built-in tools and I know that I can access custom configuration through managed code, but I needed to find some samples.&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;So I searched iis.net for some articles, tools and forum posts about this problem.&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;I found this article first:&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://www.iis.net/articles/view.aspx/IIS7/Extending-IIS7/Extending-IIS7-Configuration/Extending-IIS7-Schema-and-Accessing-the-custom-sec?Page=2"&gt;http://www.iis.net/articles/view.aspx/IIS7/Extending-IIS7/Extending-IIS7-Configuration/Extending-IIS7-Schema-and-Accessing-the-custom-sec?Page=2&lt;/A&gt;&amp;nbsp; &lt;BR&gt;This example isn’t so detailed for a c# newbie like myself and I needed an example to access collections.&amp;nbsp; &lt;BR&gt;I found an example of code accessing collections here:&amp;nbsp; &lt;A href="http://forums.iis.net/t/1026445.aspx"&gt;http://forums.iis.net/t/1026445.aspx&lt;/A&gt;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;And another one here:&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://www.iis.net/articles/view.aspx/IIS7/Extending-IIS7/Using-Microsoft-Web-Administration/Accessing-Configuration-Sections-using-Microsoft-W" mce_href="http://www.iis.net/articles/view.aspx/IIS7/Extending-IIS7/Using-Microsoft-Web-Administration/Accessing-Configuration-Sections-using-Microsoft-W"&gt;http://www.iis.net/articles/view.aspx/IIS7/Extending-IIS7/Using-Microsoft-Web-Administration/Accessing-Configuration-Sections-using-Microsoft-W&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;With these examples, I was able to write a little console application that would read and write my configuration.&amp;nbsp; A good start.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;Here is my code:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN style="mso-spacerun: yes"&gt;using System;&lt;BR&gt;using Microsoft.Web.Administration;&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt; 
&lt;P mce_keep="true"&gt;namespace PonyConsole&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; class Program&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; static void Main(string[] args)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Initialize the server manager used to administer the sections&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ServerManager serverManager = new ServerManager();&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Get the applicationHost.config file&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Configuration config = serverManager.GetApplicationHostConfiguration();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Get the custom configuration section from that file&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ConfigurationSection section = config.GetSection("ENC-Pony");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Output the default value of the booleanProperty&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(section.GetAttributeValue("CanIHaveAPonyPlease"));&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Set the new value of the booleanProperty&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; section.SetAttributeValue("CanIHaveAPonyPlease", true);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // add an item to the collection&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ConfigurationElementCollection collection = section.GetCollection("ponies");&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ConfigurationElement newElement = collection.CreateElement();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newElement.SetAttributeValue("PonyLocation", "HttpLink");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newElement.SetAttributeValue("value", "c:\\pic");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; collection.Add(newElement); &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Update the config file with the changes that you have made&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; serverManager.CommitChanges();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("Finished writing ... ");&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Output the default value of the booleanProperty&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(section.GetAttributeValue("CanIHaveAPonyPlease"));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("YesResponse is: " + section.GetAttributeValue("YesResponse"));&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("NoResponse is: " + section.GetAttributeValue("NoResponse"));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (ConfigurationElement element in section.GetCollection("ponies"))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(element.GetAttribute("PonyLocation").Value);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(element.GetAttribute("value").Value);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;At this point I had successfully written code using our new managed interface to read and write to my custom configuration properties.&amp;nbsp; Very exciting ... next post is how do I make this work in the context of an IIS pipeline module.&amp;nbsp; &lt;/P&gt;&lt;/SPAN&gt;&lt;img src="http://blogs.iis.net/aggbug.aspx?PostID=2019436" width="1" height="1"&gt;</description><category domain="http://blogs.iis.net/davcox/archive/tags/IIS7/default.aspx">IIS7</category><category domain="http://blogs.iis.net/davcox/archive/tags/Config/default.aspx">Config</category></item><item><title>Adding simple custom schema to IIS Configuration</title><link>http://blogs.iis.net/davcox/archive/2007/10/31/adding-simple-custom-schema-to-iis-configuration.aspx</link><pubDate>Wed, 31 Oct 2007 16:27:00 GMT</pubDate><guid isPermaLink="false">50bcf3b4-f6fe-4638-adff-0c150e922e99:1983559</guid><dc:creator>davcox</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.iis.net/davcox/rsscomments.aspx?PostID=1983559</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.iis.net/davcox/commentapi.aspx?PostID=1983559</wfw:comment><comments>http://blogs.iis.net/davcox/archive/2007/10/31/adding-simple-custom-schema-to-iis-configuration.aspx#comments</comments><description>&lt;P mce_keep="true"&gt;Let's see if I can get 2 blog posts written in the same month!&amp;nbsp; :)&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;As I was talking last post, our team had an app-building week (everyone will see the results over the next couple months; there were some VERY cool tools that I'm excited for people to see).&amp;nbsp; I wanted to document part of my journey on getting a custom schema added.&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;One thing that I noted is that it's important to make sure your schema file is well-formed XML, or all sorts of tools will choke in various ways.&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;I looked at the existing iis_schema.xml for examples of various elements that I could use.&amp;nbsp;&amp;nbsp; Also, this&amp;nbsp;IIS.net article is extremely helpful in getting started:&amp;nbsp; &lt;A href="http://www.iis.net/articles/view.aspx/IIS7/Extending-IIS7/Extending-IIS7-Configuration/Extending-IIS7-Schema-and-Accessing-the-custom-sec" mce_href="http://www.iis.net/articles/view.aspx/IIS7/Extending-IIS7/Extending-IIS7-Configuration/Extending-IIS7-Schema-and-Accessing-the-custom-sec"&gt;http://www.iis.net/articles/view.aspx/IIS7/Extending-IIS7/Extending-IIS7-Configuration/Extending-IIS7-Schema-and-Accessing-the-custom-sec&lt;/A&gt;&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;I ended up creating this schema:&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face=Arial size=2&gt;&amp;lt;configSchema&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;sectionSchema name="ENC-Pony"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;attribute name="CanIHaveAPonyPlease" type="bool" defaultValue="false" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;attribute name="YesResponse" type="string"&amp;nbsp; defaultValue="Yes, you can have a pony" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;attribute name="NoResponse" type="string"&amp;nbsp; defaultValue="No, you cannot have a pony" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;element name="ponies"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;collection addElement="add" &amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;attribute name="PonyLocationType" type="enum" defaultValue="AsciiFile"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;enum name="AsciiFile" value="0" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;enum name="ImageFile" value="1" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;enum name="HttpLink" value="2" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/attribute&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;attribute name="value" type="string" validationType="nonEmptyString" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/collection&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/element&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/sectionSchema&amp;gt;&lt;BR&gt;&amp;lt;/configSchema&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;
&lt;P mce_keep="true"&gt;I wanted to automate adding my custom Section to the IIS config system, so I saw that MVolo has a tool to do just that; it works great.&amp;nbsp; It's really just adding one line to applicationhost.config, but it's easier said than automated.&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;The line that needs to be added to the &amp;lt;configSections&amp;gt; element&amp;nbsp;is:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;section name="ENC-Pony" overrideModeDefault="Allow" allowDefinition="Everywhere" /&amp;gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;Here is the iisschema.exe tool which will let you add this line item automatically.&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;A href="http://mvolo.com/blogs/serverside/archive/2007/08/04/IISSCHEMA.EXE-_2D00_-A-tool-to-register-IIS7-configuration-sections.aspx" mce_href="http://mvolo.com/blogs/serverside/archive/2007/08/04/IISSCHEMA.EXE-_2D00_-A-tool-to-register-IIS7-configuration-sections.aspx"&gt;http://mvolo.com/blogs/serverside/archive/2007/08/04/IISSCHEMA.EXE-_2D00_-A-tool-to-register-IIS7-configuration-sections.aspx&lt;/A&gt;&amp;nbsp; &lt;BR&gt;&lt;A href="http://www.harbar.net/archive/2007/08/08/IISSCHEMA.EXE--A-tool-to-register-IIS7-configuration-sections.aspx" mce_href="http://www.harbar.net/archive/2007/08/08/IISSCHEMA.EXE--A-tool-to-register-IIS7-configuration-sections.aspx"&gt;http://www.harbar.net/archive/2007/08/08/IISSCHEMA.EXE--A-tool-to-register-IIS7-configuration-sections.aspx&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;At this point, I could read and write configuration through tools like appcmd and the rest of the configuration stack (including the UI Configuration Editor module).&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;The next post will be how to develop a managed module that runs in the IIS pipeline.&amp;nbsp; &lt;/P&gt;&lt;img src="http://blogs.iis.net/aggbug.aspx?PostID=1983559" width="1" height="1"&gt;</description><category domain="http://blogs.iis.net/davcox/archive/tags/IIS7/default.aspx">IIS7</category><category domain="http://blogs.iis.net/davcox/archive/tags/Schema/default.aspx">Schema</category><category domain="http://blogs.iis.net/davcox/archive/tags/Config/default.aspx">Config</category></item></channel></rss>