Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

save web.config error access denid

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

like image 654
user3651326 Avatar asked Jan 31 '26 03:01

user3651326


2 Answers

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

like image 90
MortezaDalil Avatar answered Feb 01 '26 18:02

MortezaDalil


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.

like image 43
Aniket Avatar answered Feb 01 '26 17:02

Aniket



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!