3

I have a machine.config with this configuration:

<system.web>
     <machineKey compatibilityMode="Framework20SP2" validationKey="123" decryptionKey="456" validation="SHA1" decryption="3DES"/> 

And a web.config with this attribute

 <system.web>
     <machineKey decryption="SHA1"/> 

Does the final configuration do a combination of both?

<machineKey compatibilityMode="Framework20SP2" validationKey="123" decryptionKey="456" validation="SHA1" decryption="SHA1"/> 

or if I have redefined machineKey it will get overriden completely?

 <machineKey decryption="SHA1"/> 
X.Otano
  • 2,079
  • 1
  • 22
  • 40

1 Answers1

0

Settings in child directory will either override or modify settings from parent directory. e.g. Lets take example of handlers or modules. In parent directory if web.config contains handlers like this.

<configuration>
  <system.web>
     <httpHandlers>
        <add verb="*" path="SampleHandler.new" type="SampleHandler, SampleHandlerAssembly" />
     </httpHandlers>
  </system.web>
</configuration>

and if child directory contains handlers like this

<configuration>
   <system.web>
     <httpHandlers>
        <add verb="*" path="*.SampleFileExtension" type="SampleHandler2 " />
     </httpHandlers>
   </system.web>
</configuration>

Then effective handlers available for child directory will be union of two configurations. So essentially configuration is getting modified here in child directory. If you add < clear/> tag right after < httpHandlers> tag in child directory's config file then it will override parent's configuration and only one handler which is there in child's config file will be available for child directory.

Now lets take second example. Consider configuration in question. In this case since we are re-declaring/configuring same setting in child's configuration file it will override parent's configuration settings and effective configuration will be whatever is there in child's configuration file. i.e.

<machineKey decryption="SHA1"/>

You may get more insight on how configuration works from this link. http://weblogs.asp.net/jongalloway/10-things-asp-net-developers-should-know-about-web-config-inheritance-and-overrides

Pankaj Kapare
  • 7,486
  • 5
  • 40
  • 56