I want to change web.config file appsetings values which is located in the server. i have given full permission to that folder still unable to access and edit the web.config file
while executing the code its giving error saying - Exception of type 'System.Web.HttpUnhandledException' .unable to access file resides in server
error:
System.UnauthorizedAccessException: Access to the path
'C:\Hosting\chek\demo.checks.in\wwwroot\web.config' is denied.
aspx.cs
string emailid = txtEmailid.Text.Trim();
Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath);
config.AppSettings.Settings.Remove("kumarSunlightitMailid");
config.AppSettings.Settings.Add("kumarSunMailid",emailid);
config.Save();
lblNewEmailid.Text = ConfigurationManager.AppSettings["kumarSunMailid"] + " is ur new mail id";
web.config
<appSettings>
<add key="kumarSunMailid" value="[email protected]" />
</appSettings>