title: Encrypting Connection string is giving strange error in asp.net C#
body: <p>I want to <code>Encrypt</code> my connectionstring while sending the source code for Viewing purpose. So I am doing something like this below in <code>Global.asax</code> file.</p>
  <pre><code>void Application_Start(object sender, EventArgs e) 
  {
      // Code that runs on application startup
         EncryptConnString();
  }
  
  public static void EncryptConnString()
  {
      Configuration config = System.Web.Configuration
                                       .WebConfigurationManager
                                       .OpenWebConfiguration(&quot;~&quot;);
  
      ConfigurationSection section = config.GetSection(&quot;connectionStrings&quot;);
  
      if (!section.SectionInformation.IsProtected)
      {
          section.SectionInformation.ProtectSection(&quot;RsaProtectedConfigurationProvider&quot;);
          config.Save();
      }
  }
  </code></pre>
  <p>but at this line <code>config.Save();</code> I am getting some strange Error which is below</p>
  <blockquote>
  <p>An exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll but was not handled in user code</p>
  <p>Additional information: An error occurred executing the configuration section handler for connectionStrings.</p>
  </blockquote>
  <p>I am unable to find the reason of it as it is the standard code to Encrypt it. Please suggest what might be the cause</p>