I'm trying to encrypt a custom section in a web.config file.
When I get to the line that calls ProtectSection(), I get an exception saying the provider isn't found.
Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
ConfigurationSection section = config.GetSection("MySection");
section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
I tried it with RSA as well and got the same error.
Running aspnet_regiis.exe works, but I need to do this programatically. What am I missing?
Thank you.