我想更改位于服务器中的web.config文件追加值。我已给予该文件夹完全权限,该文件夹仍无法访问和编辑web.config文件。
while executing the code its giving error saying - Exception of type 'System.Web.HttpUnhandledException' .unable to access file resides in server 错误:
System.UnauthorizedAccessException:访问路径 'C:\Hosting\chek\demo.checks.in\wwwroot\web.config‘被拒绝。
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="krishna@gmail.com" />
</appSettings>发布于 2015-06-11 11:44:30
您正面临此错误,因为您不给用户读/写权限。 检查几件事
发布于 2015-06-11 12:33:51
如果您没有尝试过这种方法,请尝试将Everyone用户添加到该文件夹中,并给予他完全的访问权限。接下来,可以尝试设置应用程序设置的configSource,以便将这些设置存储在单独的配置文件中:
<appSettings configSource="appSettings.config" />然后在名为appSettings.config的文件夹中创建一个新文件:
<?xml version="1.0" encoding="UTF-8"?>
<appSettings>
<add key="yourKey" value="yourValue" />
</appSettings>尝试添加对两个文件都具有完全访问权限的Everyone用户。
否则,我会创建一个新的解决方案,看看您是否可以在那里重新创建这种奇怪的行为。
发布于 2017-03-20 08:53:55
请允许当前用户完全访问iis项目或解决方案。
https://stackoverflow.com/questions/30779744
复制相似问题