【发布时间】:2010-07-29 05:44:50
【问题描述】:
我想在 web.config 中提供来自数据库的用户名、密码和 APIKey 的值。意味着无论管理员设置的用户名、密码、APIkey 必须在 web.config 中设置。 我怎样才能改变这个。任何想法。
谢谢。
【问题讨论】:
标签: asp.net
我想在 web.config 中提供来自数据库的用户名、密码和 APIKey 的值。意味着无论管理员设置的用户名、密码、APIkey 必须在 web.config 中设置。 我怎样才能改变这个。任何想法。
谢谢。
【问题讨论】:
标签: asp.net
private void UpdateConfig(string strKey, string strValue)
{
Configuration objConfig =
WebConfigurationManager.OpenWebConfiguration("~");
AppSettingsSection objAppsettings =
(AppSettingsSection)objConfig.GetSection("appSettings");
if (objAppsettings != null)
{
objAppsettings.Settings[strKey].Value = strValue;
objConfig.Save();
}
}
但是每次更新 web.config 文件都会重启你的应用域,所以不建议频繁更新 web.config。
【讨论】: