title: Encrypt custom config section in ASP.NET using aspnet_regiis
body: <p>We are using a custom config section (via the NameValueConfigSection) to contain our settings.
  These settings are externalised from web.config via configSource.</p>
  
  <p>So, entries in web.config look something like this:</p>
  
  <pre><code>  &lt;configSections&gt;
      &lt;section name="customSettings" type="System.Configuration.NameValueSectionHandler" /&gt;
    &lt;/configSections&gt;
  
    &lt;customSettings configSource="config\customSettings.config" /&gt;
  </code></pre>
  
  <p>We want to encrypt this "customSettings.config" file on our production server, so run this command, as recommended by Microsoft (here: <a href="http://msdn.microsoft.com/en-us/library/zhhddkxy.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/zhhddkxy.aspx</a>)</p>
  
  <pre><code>aspnet_regiis -pe customSettings -site 4 -app /
  </code></pre>
  
  <p>And this produces the following output:</p>
  
  <pre><code>Encrypting configuration section...
  Succeeded!
  </code></pre>
  
  <p><strong>However, it does not succeed at all, leaving the file exactly as it was</strong></p>
  
  <p>(incidentally, this command <em>does work</em> if encrypting a non-custom section, such as an externalised connectionStrings section)</p>
  
  <p>I have been able to write a little console app that does work ok, but we really want to use the standard tools to do what should be a standard operation - can anyone tell me if this is a limitation or where I am going wrong?</p>
  
  <p>Thanks :)</p>