[英]web.config in asp.net
i want to give the values of username,password and APIKey in web.config which are coming from database.means whatever the admin set username,password,APIkey that has to be set in web.config. 我想在web.config中提供来自数据库的username,password和APIKey的值。这意味着必须在web.config中设置管理员设置的username,password和APIkey。 how can i change this.Any idea.
我该如何更改。任何想法。
thank you. 谢谢。
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();
}
}
But it will restart your application domain every time you update the web.config file, so, updating the web.config frequently is not advisable. 但是,每次您更新web.config文件时,它将重新启动您的应用程序域,因此,不建议频繁更新web.config。
Pls refer : Editing Web.config programatically 请参考:以编程方式编辑Web.config
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.