Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AppSettings Clear Xml element in app.config

What is the purpose of the <Clear \> XML element within the <AppSettings> tag in an application's config file?

I see it removes previously added settings (see code below), but why would you want to do that?

<appSettings>
  <add key="LogInformation" value="False"/>
  <add key="LogAPIMessages" value="False"/>
  <add key="LogErrors" value="True"/>
  <clear/> <!--This line removes previously added keys.-->
</appSettings>

I also understand that when manipulating app settings in code you could clear existing keys, but why have the <clear\> XML element?

Also, out of habit really, i've been putting the <clear\> element before any <add> elements. Do i need to do this, should i not be doing this?

like image 275
George Duckett Avatar asked Jun 13 '11 13:06

George Duckett


1 Answers

This is applicable in scenarios when you have a web application within another web application. E.g you implement blog as a seperate application within your main application. Then in such cases "clear" is used to remove all references to inherited custom application settings, which are inherited from the parent application settings.

like image 115
Hasan Fahim Avatar answered Sep 28 '22 03:09

Hasan Fahim