Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aspnet_regiis section not found

Tags:

asp.net

iis

i'm trying to encrypt my web.config.

aspnet_regiis keeps telling me: The configuration section 'applicationSettings' was not found.

I followed this site: Walkthrough: Creating and Exporting an RSA Key Container

My web.config looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>

    <configSections>
        <section name="x" type="x" />
     <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
   <section name="x.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </sectionGroup>
 </configSections>

    <configProtectedData>
      <providers>
         <add name="MyProvider"
              type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0. 0.0,
                    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
                    processorArchitecture=MSIL"
              keyContainerName="MyKeys" 
              useMachineContainer="true" />
      </providers>
   </configProtectedData>

... 

  <applicationSettings>
    <x.Properties.Settings>
      <setting name="PollingInterval" serializeAs="String">
        <value>10000</value>
      </setting>
    </x.Properties.Settings>
  </applicationSettings>
</configuration>

I use the command: aspnet_regiis -pe "applicationSettings" -app "/MyApplication" -prov "MyProvider"

When I move the Section configProtectedData above the configSections it encrypts the applicationSettings, but removes the configSections-Section, anyway, IIS tells me configSections need to be the first element. I'm not sure what I'm doing wrong.

Is it a problem, that the applicationSettings is listed in the configSections?

Thank you for your help.

like image 878
takko Avatar asked Dec 16 '22 12:12

takko


1 Answers

Ok, found the solution,

as stated in "configSections", "applicationSettings" is a SectionGroup, not a Section. aspnet_regiis can only encrypt Sections.

so I had to go one deeper: aspnet_regiis -pe "applicationSettings/x.Properties.Settings" -app "/MyApplication" -prov "MyProvider"

like image 176
takko Avatar answered Jan 16 '23 04:01

takko