Click here to Skip to main content
15,915,869 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

C#
var config = Misconfiguration.OpenWebConfiguration("~");
config.AppSettings.Settings["name"].Value = txt1.Text;

config.Save(ConfigurationSaveMode.Modified);


any idea? thanks
Posted
Comments
KaushalJB 23-May-14 6:26am    
Remove read only from your E drive...and allow full control to your user
NewWebDesigner 23-May-14 6:40am    
but i run in server no in my computer!i dont see the user name!
when i run code in localhost no error.but on server error was occured

you have permission issue and need to give read write access to your iis web application app pool user.
check below thread
http://forums.asp.net/post/1991662.aspx[^]
 
Share this answer
 
v2
Comments
NewWebDesigner 23-May-14 6:51am    
i do it.but same error occured!
NewWebDesigner 23-May-14 6:58am    
web.config is on server.how i can right click and set permission?
please help me.
If you are using shared web hosting you should be able to do this through the control panel for your account. There will be an area where you can set permissions for folders and files. Check with your host for this information.

If you are using a VPS or dedicated server you can use remote desktop to connect to the server and set the permissions that way.

Just a general note, it is not really a good practice to set your web.config to read/write. If you need to set a value during an app install you should make sure the web.config is set to read only afterwards.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900