Saturday, March 14, 2009

Difference between clear and remove in web.config

Hi all,

I had a discussion with one of my friends about the difference between clear and remove keys in web.config, and I would like to share it with you.
Remove in web.config is to remove a specific key from the web.config, for example:
Note: <> have been replaced by {} because it is not allowed to be posted in http request.

{appSettings}
{add key="MyName" value="Mostafa1"/}
{add key="MyName" value="Mostafa2"/}
{add key="MyName1" value="Mostafa3"/}
{remove key="MyName1"/}
{/appSettings}
Remove is removing the key MyName1.
Clear is used to remove all key mentioned above it, for example:
{appSettings}
{add key="MyName" value="Mostafa1"/}
{add key="MyName" value="Mostafa2"/}
{add key="MyName1" value="Mostafa3"/}
{clear/}
{/appSettings}
I don’t recommend to use clear key in the web.config because it will cause a disaster in your application.
Hope this tip helps.
Post a Comment