Writing to web.config (asp.net)

My openconfigurationmanager call is failing due to trust level medium. I want to be able to provide a change feature for some web.config app settings. Is there any way around it?

I am assuming I can not change the trust level to full. Can I?
 
You can't get full trust but you can probably ask support to set permissions to be the same as they set for DotNetNuke. DNN certainly writes to the web folder, creates folders etc. I don't know if DNN writes to web.config but its just another file.
 
DNN does write to web.config (for some custom modules) and does so correctly with the permissions Jodo gives.

Make sure it is in your root folder.
 
During the development our software (http://jumptree.com), we had the same issues due to the need for full trust if configurationManager is needed.

Maybe it works in certain settings, but we can't be sure if it'll work on ANY medium trust enabled hosting for our customers.

So what we did was to extract the part of the web.config into its own xml file. For example, AppSettings. In our web.config, we did

<appsettings file="PMAppSettings.config" />

and use XmlDocument/XmlTextWriter to read and write to "PMAppSettings.config".

Worked extremely well with the added benefit of easy deployment for customers without changing the main web.config file.

Hope that helps.
 
Back
Top