title: RSA key container could not be opened
body: <p>I've been working on a project to move all of our applications to use external .config files to store connection strings so they are no longer kept in source control. As part of this, we are now encrypting these connection strings on deployment.</p>
  
  <p>web.config</p>
  
  <pre><code>&lt;connectionStrings configSource="ConnectionStrings.config"/&gt;
  </code></pre>
  
  <p>ConnectionStrings.config</p>
  
  <pre><code>&lt;connectionStrings&gt;
      &lt;add name="MyDatabase" connectionString="MyConnectionString" providerName="System.Data.SqlClient"&gt;
  &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>This is an application that I had to update from <code>.NetFramework 4.0</code> to <code>.NetFramwork 4.7.2</code> due to restrictions on our build server.</p>
  
  <p>To encrypt the connection strings I have been running the following command (on the web server) for all of our applications thus far with no issue. Several of these were framework upgrades as well. Note: we give each of our web apps their own app pool.</p>
  
  <pre><code>"C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe" -pe "connectionStrings" -app "/MyApplication" -site "Default Web Site"
  </code></pre>
  
  <p>Every site so far has worked without issue in all of our environments. Now this most recent one, when encrypted, causes an infinite redirect loop with the same error each loop of </p>
  
  <blockquote>
    <p>Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: The RSA key container could not be opened.</p>
  </blockquote>
  
  <p>If I go to the server and run the command line to decrypt, it succeeds and the app functions properly. I'm baffled and non of my coworkers have any idea either. I know it has to be something specific to this one application but I don't know where to begin. It is an old app that I didn't even work on and know nothing about. I've looked through numerous pages of similar RSA complaints but none of them seem to be this specific issue. And yes I am able to replicate this on multiple servers and even on my own machine.</p>