I've been all over google, MSDN, and Stack Overflow, but I can't find a full tutorial on how to do this.
I want to add a password to my Web.config file for an ASP.NET Web app, and I want to encrypt it. How do I do this?
You want to add a section because the aspnet_regiis
will encrypt sections at a time, and you probably have config settings you don't want to encrypt.
The configuration section 'secureAppSettings' was not found
. Use the Web.config in your main Web project.<configSections>
<section name="secureAppSettings" type="System.Configuration.NameValueSectionHandler" />
</configSections>
<secureAppSettings>
<add key="Password" value="1234567890"/>
</secureAppSettings>
AppSettingsSection
didn't work for me, but NameValueSectionHandler did.string p = ((NameValueCollection)WebConfigurationManager.GetSection("secureAppSettings"))
["Password"];
Administrator
.aspnet_regiis -pef "secureAppSettings" "C:\folder\with\the_config_file"
If you use a Web.config section of type, System.Configuration.AppSettingsSection
you will probably run into this error. Could not load type 'System.Configuration.AppSettingsSection' from assembly 'System.Web'
I could not get the AppSettingsSection to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With