views:

30

answers:

1

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.

A: 

If you are trying to us Windows Data Protection Provider shouldnt the parameter passed to ProtectSetion say "DpapiProtectedConfigurationProvider".

For RSA it should be "RsaProtectedConfigurationProvider" which is default and preffered option

Vinay B R
I gave this a try, but still got the same error:Unable to encrypt MySection. The protection provider 'DpapiProtectedConfigurationProvider' was not found.Unable to encrypt MySection. The protection provider 'RsaProtectedConfigurationProvider' was not found.