Reputation: 4070
I have an applicationSettings section in my web.config in my ASP.NET 2.0 web application. This works perfectly for storing values and being able to access them as strongly-typed values.
Here is a snippet of my web.config:
<configuration>
...
<applicationSettings>
<MyWebsite.Properties.Settings>
<setting name="ExcludedItemNumbers" serializeAs="Xml">
<value>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<string>123</string>
<string>124</string>
</ArrayOfString>
</value>
</setting>
</MyWebsite.Properties.Settings>
</applicationSettings>
</configuration>
However, I have another Virtual Directory below this on the IIS server (which by default inherits this web.config). After adding the applicationSettings to this web.config, the child Virtual Directory throws a runtime error complaining of a bad web.config (I'm assuming because MyWebsite.Properties.Settings is not a valid type in the child site).
How can I keep the strongly-typed access to my settings in this site and not break the site that is inheriting this web.config? I have tried doing the location tag around the applicationSettings tag, but that gives a runtime error on this site.
Upvotes: 2
Views: 1178
Reputation: 25638
You can also use the remove element:
<appSettings>
<settings>
<remove key="someKey" />
<add key="someKey" value="a new value" />
</settings>
</appSettings>
Upvotes: 1
Reputation: 1230
You can add the clear element to your child web.config file.
<appSettings file="">
<settings>
<clear />
</settings>
</appSettings>
Upvotes: 1