I have an asp.net application. There are secret parts contained in the web.config file which I want to protect through encryption. I'm using the ConfigurationSection.SectionInformation.ProtectSection method and later using WebConfigurationManager.Save to save it. Locally it works OK.
The problems is when it runs on the server, I get this error:
System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: (C:\Inetpub\vhosts(SiteName)\httpdocs\web.config) ---> System.UnauthorizedAccessException: Access to the path 'C:\Inetpub\vhosts(SiteName)\httpdocs\rz0fkykb.tmp' is denied.
This problems seems to take place because there is no write permission for the temp file which is obviously being created as part of encrypting the parts in web.config. I don't know the name of the temp file to be created and I don't want to give total write permission to the whole basic directory (security).
Is there a way to configure the path or the name of the tmp file created as side effect of the web.config encryption so I can isolate it and give to it (or to the custom specific directory) writing permissions?