i search but i cant find a solution for this problem. when i want to save web.config i recieve this error:
An error occurred loading a configuration file: Access to the path 'E:\vhosts\some.ir\httpdocs\egqz2vnh.tmp' is denied.
i use this code for access and save webconfig:
var config = Misconfiguration.OpenWebConfiguration("~");
config.AppSettings.Settings["name"].Value = txt1.Text;
config.Save();
i use Plesk for upload website.do need set permission for current user to access web.config in ftpaccess?
any idea? thanks
Modify your website folder permssion. For example with plesk (in file manager), I clicked on "change access right to the file or directory" (for website container directory , not web.config). Then I changed permissions on "Default Plesk application pool user (IWAM_plesk(default))".
Hope it helps
Try this :
using System.Web.Configuration;
using System.Configuration;
Configuration config = WebConfigurationManager.OpenWebConfiguration("/");
string oldValue = config.AppSettings.Settings["name"].Value;
config.AppSettings.Settings["name"].Value = "ABC";
config.Save(ConfigurationSaveMode.Modified);
<appSettings>
<add key="name" value="XYZ" />
</appSettings>
after the execution value field would be changed to ABC.
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