Is it possible to protect a single element in the appSettings section instead of the entire section?
Posted
by hambonious
on Stack Overflow
See other posts from Stack Overflow
or by hambonious
Published on 2010-04-28T19:19:35Z
Indexed on
2010/04/28
19:27 UTC
Read the original article
Hit count: 315
I would like to protect one key/value pair in my appSettings but not the others using something like I've previously done with the ProtectSection method as seen below.
var configurationSection = config.GetSection("appSettings");
configurationSection.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
Ideally I would like to do something like the following:
var configurationElement = config.GetSection("appSettings").GetElement("Protected");
configurationElement.ElementInformation.ProtectElement("DataProtectionConfigurationProvider");
Here is the example appSettings I would be operating on:
<configuration>
<appSettings>
<add key="Unprotected" value="ChangeMeFreely" />
<add key="Protected" value="########"/>
</appSettings>
</configuration>
I've been searching but haven't found a way to do this. Is this possible?
© Stack Overflow or respective owner