无法写入生产服务器上的web.config的AppSettings [英] Unable to write AppSettings of web.config on production server
问题描述
我已经写了下面的code来更改在web.config的AppSettings值,当我测试它在我的dev的机器,它工作正常。不过,我复制页面到生产服务器后,改变值不更新。
I've written following code to make changes to the values of AppSettings in the web.config and when I tested it on my dev machine, it works fine. However, after I've copied the page to the production server, changing the values are not updated.
Configuration myConfig = WebConfigurationManager.OpenWebConfiguration("~");
try
{
myConfig.AppSettings.Settings["username"].Value = txtUsername.Text;
myConfig.AppSettings.Settings["password"].Value = txtPassword.Text;
myConfig.AppSettings.Settings["senderNum"].Value = txtSMSCenter.Text;
myConfig.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
lblStatus.Text = "Config updated at: " + DateTime.Now.ToString();
}
catch (ConfigurationException ex)
{
lblStatus.Text = ex.Message;
}
对于管理员
我已经允许进行写访问,网络服务和IIS_IUSRS到web.config中,但仍然无法正常工作。
I've allowed write access for Administrator, Network Service and IIS_IUSRS to web.config but still doesn't work.
有何意见?
推荐答案
尝试检查该网站;
的如何使用C#改变App.config文件运行时
How to change App.config file run time using C#
<一个href=\"https://forums.asp.net/t/1383388.aspx/1?Modify%20web%20config%20appSettings%20at%20run%20time%20by%20$c$c%20behind\"相对=nofollow>修改由code在运行时的web.config的appSettings背后
<一个href=\"http://stackoverflow.com/questions/719928/how-do-you-modify-the-web-config-appsettings-at-runtime\">How你修改web.config的appSettings在运行时?
问候
这篇关于无法写入生产服务器上的web.config的AppSettings的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!